我正在学习科多瓦教程,并尝试在GopherJS中做练习。我安装了“设备”插件(cordova plugin add cordova-plugin-device),并试图获取设备的字段:
type (
Info struct {
*js.Object
Cordova string `js:"cordova"`
Model string `js:"model"`
Platform string `js:"platform"`
Serial string `js:"serial"`
UUID string `js:"uuid"`
Version string `js:"version"`
}
)
var device = &Info{Object: js.Global.Get("device")}但它们是空的。我怎么能读到它们?有什么办法让GopherJS从*js.Object中填充字段吗?
发布于 2018-04-25 20:50:42
我想通了。我需要等待直到deviceready事件发生:
var device *Info
// ...
func onDeviceReady(dom.Event) {
device = &Info{Object: js.Global.Get("device")}
}https://stackoverflow.com/questions/50031084
复制相似问题