從A小程序跳轉到B小程序

從A小程序跳轉到B小程序:

A小程序 wxml:

<navigator target="miniProgram" open-type="navigate" app-id="wx82b7c63d360a3b10" path="pages/personal/personal" extra-data="{{dataList}}" version="release" /> 

註釋:json

1. app-id 設置要跳轉的小程序的APPID 2. path 配置跳轉後進入的頁面 3. extra-data 能夠設置要攜帶的數據,該參數是一個對象 4. version是要打開的小程序版本,有效值: develop(開發版),trial(體驗版),release(正式版),僅在當前小程序爲開發版或體驗版時此參數有效;若是當前小程序是正式版,則打開的小程序一定是正式版。

A小程序 app.json:

{
  "navigateToMiniProgramAppIdList": [ "wx82b7c63d360a3b10" ] } 

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小程序攜帶的對象app

相關文章
相關標籤/搜索