代码拉取完成,页面将自动刷新
//bin/echo; [ $(uname) = "Darwin" ] && FLAGS="-framework Webkit" || FLAGS="$(pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.0)" ; c++ "$0" $FLAGS -std=c++11 -g -o webview && ./webview ; exit
// +build ignore
#include "webview.h"
#include <iostream>
#ifdef _WIN32
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
#else
int main()
#endif
{
webview::webview w(true, nullptr);
w.set_title("Example");
w.set_size(480, 320, WEBVIEW_HINT_NONE);
w.set_size(180, 120, WEBVIEW_HINT_MIN);
w.bind("noop", [](std::string s) -> std::string {
std::cout << s << std::endl;
return s;
});
w.bind("add", [](std::string s) -> std::string {
auto a = std::stoi(webview::json_parse(s, "", 0));
auto b = std::stoi(webview::json_parse(s, "", 1));
return std::to_string(a + b);
});
w.navigate(R"(data:text/html,
<!doctype html>
<html>
<body>hello</body>
<script>
window.onload = function() {
document.body.innerText = `hello, ${navigator.userAgent}`;
noop('hello').then(function(res) {
console.log('noop res', res);
});
add(1, 2).then(function(res) {
console.log('add res', res);
});
};
</script>
</html>
)");
w.run();
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。