相关文档链接:https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateto.html
使用示例如下
页面a
wx.navigateto({ url: 'pages/pageb', success: function(res) { // 通过eventchannel向被打开页面传送数据 res.eventchannel.emit('gopageb', { pagedataa: '页面a传递到页面b的数据' }) }})
页面b
onload: function(){ const eventchannel = this.getopenereventchannel() // 监听gopageb事件,获取上一页面通过eventchannel传送到当前页面的数据 eventchannel.on('gopageb', function(data) { console.log('页面a传递的数据:',data) }) }
这种小程序特有的传参方式相比拼接url传参虽然过程稍微麻烦一些,但是不需要对参数进行相关的转换,也不用对一些特殊字符串进行处理
推荐教程:《微信小程序》
以上就是微信小程序特有页面间传参方式的详细内容。
