为什么自定义组件中的bindtap绑定的getback事件苹果手机生效,安卓机不生效。自定义组件设置的用来绝对定位,层级都设置了1000,经过请求函数,订阅消息后,苹果手机可以生效,安卓就是不生效。
if (res.code == '200') {
wx.requestSubscribeMessage({
tmplIds: ['CIYiPiMtNFSmX1tx93jfN4taC6to1m-uwZRj5YDFa-I','pP2NHUk-vhfC6uZT8e_37ZN0f29ketiH3_sVAR1DVms','wkNEEXnVgjF7BNVZHp1JL71HRl-Rmp6YwTFkpT0fxs4'],
success :function(res) {
that.selectComponent("#popup").showPopup();
},
fail(res){
that.selectComponent("#popup").showPopup();
}
})
自定义组件内函数
showtime() {
//每秒执行一次,showTime()
let t = 4;
let that = this;
var timer = setInterval(function () {
t -= 1;
that.setData({
timenumber: t
})
if (t == 0) {
that.setData({
flag: false
})
wx.switchTab({
url: '/pages/index/index'
})
clearInterval(timer);
}
}, 1000);
},
getback() {
console.log(1)
let that = this
this.setData({
flag: !this.data.flag
})
wx.switchTab({
url: '/pages/index/index'
})
this.triggerEvent('myevent', {
params: true
})
},
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
搞了代码片段这边看下 https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html
这里其实不是点击事件没有生效,而是你在点击事件的回调函数中调了接口,又在接口请求的回调函数中调了微信的消息订阅,wx.requestSubscribeMessage()从2.8.2版本开始,用户发生点击行为或支付回调后才可以调用订阅消息功能。不能在接口请求的回调里调用。https://developers.weixin.qq.com/miniprogram/dev/api/open-api/subscribe-message/wx.requestSubscribeMessage.html