在自定义组件内部调用wx.navigateTo方法,目标页面eventChannel.on无法监听?

发布于 5 年前作者 yangzhu9681 次浏览最后编辑 5 年前来自 ask
// 跳转页面(内嵌的自定义组件内的方法)
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 回复
xiulanyu
xiulanyu1 楼8 个月前

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