🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] > [github](https://github.com/zserge/webview) ## demo 开发模式下可以按 快捷方式调出 控制台 ``` debug := true w := webview.New(debug) defer w.Destroy() w.SetTitle("Minimal webview example") w.SetSize(800, 600, webview.HintNone) //w.Navigate("https://www.baidu.com") w.Navigate(`data:text/html, <!doctype html> <html> <body>hello</body> <script> window.onload = function() { document.body.innerText = ` + "`hello, ${navigator.userAgent}`" + `; noop().then(function(res) { console.log('noop res', res); add(1, 2).then(function(res) { console.log('add res', res); quit(); }); }); }; </script> </html> )`) w.Init("alert('123')") w.Run() ``` ## 编译成 app ``` # Linux $ go build -o webview-example && ./webview-example # MacOS uses app bundles for GUI apps $ mkdir -p example.app/Contents/MacOS $ go build -o example.app/Contents/MacOS/example $ open example.app # Or click on the app in Finder # Windows requires special linker flags for GUI apps. # It's also recommended to use TDM-GCC-64 compiler for CGo. # http://tdm-gcc.tdragon.net/download $ go build -ldflags="-H windowsgui" -o webview-example.exe ```