Estou iniciando um novo projeto e vi uma biblioteca muito interessante para GO que é um pouco parecida com o fasthtml, chamada go-app.
Estou com dificuldades para executar comandos JS simples como console.log ou alert. Ou estou esquecendo de algo?
type Button struct {
app.Compo
}
func (b *Button) OnClick(ctx app.Context, e app.Event) {
// NONE of these codes works when clicking the button.
//e.JSValue().Call("alert", "e jsvalue call Button clicked!")
//ctx.JSSrc().Call("alert", "ctx jssrc call Button clicked!")
//app.Window().Get("alert").Call("window get call Hello world")
//app.Window().Call("alert", "window call Button clicked!")
app.Window().Get("console").Call("log", "window get call log")
}
func (b *Button) Render() app.UI {
return app.Button().
ID("button").
Text("Click me!").
OnClick(b.OnClick)
}
Tente isto se funcionar: