eventChannel真机调试不能传递信息?
发布于 5 年前 作者 ppeng 6088 次浏览 来自 官方Issues

需要在页面间传递信息,使用:

发送页面源码:

  let index = e.currentTarget.dataset.index

console.log(‘jump to season:’, index)

wx.navigateTo({url: ‘…/season/season’, success:function(res){res.eventChannel.emit(‘sendSeasonNo’, index)}})

接收页面源码:

  var tmp

eventChannel.on(‘sendSeasonNo’, function(data){tmp=data})

开发工具调试正常,但是真机调试,在执行完eventChannel.on之后,tmp还是undefined。

3 回复

我和你遇到的问题一模一样,在接受页面的 onshow 中,代码执行的顺序除了问题,先执行了后面的业务逻辑,然后才执行获取上一页传过来的数据这个动作,导致后面的业务逻辑代码获取不到数据,然后报错。不知道你最后怎么解决的

谢邀,解决了就好

emit 接收的参数是一个对象

回到顶部