从A小程序跳转到B小程序
A小程序 wxml
<navigator target="miniProgram" open-type="navigate" app-id="wx12345678" path="pages/index/index" extra-data="{{dataList}}" version="release" />
注释:
- app-id 设置要跳转的小程序的APPID
- path 配置跳转后进入的页面
- extra-data 可以设置要携带的数据,该参数是一个对象
- version是要打开的小程序版本,有效值: develop(开发版),trial(体验版),release(正式版),仅在当前小程序为开发版或体验版时此参数有效;如果当前小程序是正式版,则打开的小程序必定是正式版。
A小程序 app.json:
{
"navigateToMiniProgramAppIdList": [
"wx12345678"//小程序appid
]
}
B小程序通过在onload函数或者onShow函数中可以接收到,通过路径或者extra-data携带过来的参数
B小程序app.js:
onShow: function (options) {
console.log(options)
console.log(options.referrerInfo)
if (options.referrerInfo) {
if (options.referrerInfo.extraData) {
this.data.lotteryId = options.referrerInfo.extraData.id
//获取共享抽奖派发的代金券id
if (options.referrerInfo.extraData.type == 2) {
this.data.lotteryVoucherId = options.referrerInfo.extraData.vouchersId
}
//获取共享抽奖派发的搜城币数量
if (options.referrerInfo.extraData.type == 5) {
this.data.lotteryNumber = options.referrerInfo.extraData.number
}
}
}
},
options.referrerInfo.extraData则是A小程序携带的对象