我正在使用构建 wasm 文件以在我的浏览器上运行,我能够将简单的整数字符串值传递给方法,但不能传递复杂的对象、键值对或数组
这是我的方法
func Transform(jsV js.Value, inputs []js.Value) interface{} {
message := inputs[0].String()
fmt.Println(inputs) // How to access objects here
h := js.Global().Get("document").Call("getElementById", "message")
h.Set("textContent", message)
return nil
}
func init() {
fmt.Println("Hello, WebAssembly!")
c = make(chan bool)
}
func main() {
js.Global().Set("Transform", js.FuncOf(Transform))
println("Done.. done.. done...")
<-c
}
当我传递对象时{name:"Something"},它只打印对象,我在文档中搜索但找不到任何链接
梵蒂冈之花