Android原生插件
现象:插件的方法能正常运行,就是发送了mUniSDKInstance.fireGlobalEventCallback,uni这边的globalEvent监听不到消息,也不报错。
在onLoad中,接收页面传递参数时未判空,离线打包无任何错误提示,打包插件uni也不会有错误提示,即
//引发不起作用的原因
onLoad(options){
if (JSON.parse(options.print)) {
console.log("TO DO")
}
globalEvent.addEventListener('myEvent', (e) => {
console.log("myEvent:", JSON.stringify(e))
});
}
正确方式;
对options进行判空
onLoad(options){
if(optins!=null){
if (JSON.parse(options.print)) {
console.log("TO DO")
}
globalEvent.addEventListener('myEvent', (e) => {
console.log("myEvent:", JSON.stringify(e))
});
}
}
0 个评论
要回复文章请先登录或注册