在自定义组件内部调用wx.navigateTo方法,目标页面eventChannel.on无法监听?
发布于 3 年前 作者 yangzhu 9340 次浏览 来自 问答
// 跳转页面(内嵌的自定义组件内的方法)
wx.navigateTo({
        url: "/" + targetUrl.trim(),
        success: function(res) {
          console.log('sepopupsepopup', targetUrl)
          if(targetUrl.indexOf('sepopup') > 0) {
            res.eventChannel.emit('taskpage', { from: 'tasklist' })
          }
        },
        fail: function (e) {
          cb && cb();
        }
 });
//目标页面
onLoad(){
const eventChannel = this.getOpenerEventChannel()
    eventChannel.on && eventChannel.on('taskpage', function(data) {
      debugger
      if(data.from === 'tasklist') {
        wx.removeStorage({
          key: 'wxpopupTimeCount'
        })
      }
    })
}

1 回复

请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部