app.js:
onShow(options){
const scene = decodeURIComponent(options.scene || 0) ;
if(scene != '0'){
this.globalData.scene = scene;
}
if(options.openid){
this.globalData.scene = options.openid
}
if(options.query&&options.query.scene){
this.globalData.scene = options.query.scene
}
if(options.query&&options.query.openid){
this.globalData.scene = options.query.openid
}
}
关于appjs里面的onshow,开发文档找了好久没有详细介绍。现在是要获取用户分享出来连接里的参数 ?openid='fasdfadfasdfds',有时候发现query里面的scene的值是对的,有时候query.openid的值是对的。偶尔出现query为空对象的情况,但是场景值1007肯定是用户分享出去带参数的。
现在问题是不知道啥时候会出现query为空对象,导致直接把scene=1007等场景值直接存到openid字段了
问题补充:扫码进入的时候通过options.query.scene获取,通过分享进入的时候是options.query.openid获取。只是偶尔获取不到,是不是我写的有问题?
要获取分享的时候,路径上的带的参数,为啥不在页面中获取,要在app.js中获取