@@ -2,17 +2,16 @@ package main
22
33import webview "github.com/webview/webview_go"
44
5- const html = `<html style="background: #1B2845; color: #eee;">
6- <button onclick="increment();">Tap me</button>
5+ const html = `<button id="increment">Tap me</button>
76<div>You tapped <span id="count">0</span> time(s).</div>
87<script>
9- const counter = document.getElementById("count")
10- async function increment() {
11- const result = await window.Increment()
12- counter.textContent = result.count ;
13- }
14- </script>
15- </html >`
8+ const incrementBtn = document.getElementById("increment");
9+ const counter = document.getElementById("count");
10+ incrementBtn.addEventListener("click", async () => {
11+ const result = await window.increment() ;
12+ counter.textContent = result.count;
13+ });
14+ </script >`
1615
1716type IncrementResult struct {
1817 Count uint `json:"count"`
@@ -26,7 +25,7 @@ func main() {
2625 w .SetSize (480 , 320 , webview .HintNone )
2726
2827 // A binding that increments a value and immediately returns the new value.
29- w .Bind ("Increment " , func () IncrementResult {
28+ w .Bind ("increment " , func () IncrementResult {
3029 count ++
3130 return IncrementResult {Count : count }
3231 })
0 commit comments