I’ve the below code where the function attached properly to the button onclick
event:
func f(this js.Value, args []js.Value) interface{} {
println("hello world")
return nil
}
btn.Set("onclick", js.FuncOf(f))
I tried to pass args for this function as:
btn.Set("onclick", js.FuncOf(f).Invoke("Hello World"))
And manipulate it in the js.Func
as:
for x := range args {
println(x)
}
But I got the error:
wasm_exec.js:421 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'exports')
at syscall/js.valueInvoke (wasm_exec.js:421)
at syscall_js.valueInvoke (main.wasm:0x133521)
at syscall_js.Value.Invoke (main.wasm:0x131300)
at main.html (main.wasm:0x25b572)
at main.main (main.wasm:0x25e591)
at runtime.main (main.wasm:0x7f285)
at wasm_pc_f_loop (main.wasm:0xddf81)
at wasm_export_run (main.wasm:0xddf54)
at global.Go.run (wasm_exec.js:577)
at init (wasm.js:7)
Any thought?