1: 使用 wx.navigateTo 进行页面跳转传参
传入:
wx.navigateTo({ url:'/page/testPage/testPage/', success: function (res) { res.eventChannel.emit('getParamsData', pageParams) //触发事件 pageParams 为传递参数 } })
接收:(接收页面)
onLoad: function(options) { const eventChannel = this.getOpenerEventChannel() eventChannel.on("getParamsData",data => { console.log(data) }) }
2: 使用 encodeURIComponent decodeURIComponent 对传参进行转码
传入:
wx.redirectTo({ url: `/pages/testPage/testPage?params=${encodeURIComponent(JSON.stringify(testParams))`
})
接收:(接收页面)
onl oad: function (options) { const param = JSON.parse(decodeURIComponent(options.testParams)) }
标签:传参,function,过长,微信,testPage,eventChannel,options,wx From: https://www.cnblogs.com/hspl/p/17255139.html