美文网首页
微信小程序对接外部小程序跳转传参

微信小程序对接外部小程序跳转传参

作者: 哆啦C梦的百宝箱 | 来源:发表于2023-03-08 19:29 被阅读0次
  1. 跳转传参
const params = { name:'xiaoxiao',age:18};
const urlParams = encodeURIComponent(Base64.encodeURI(JSON.stringify(params)))
wx.navigateToMiniProgram({
    appId:'xxx',
    path:'xxx',
    extraData:{urlParams},
    success:(res)=>{console.log('打开成功的回调')}
})
  1. 接收参数
    可以在onShow和onLaunch中接收
    在app.js中,可以把参数作为全局变量存起来,如果其他页面要使用
onShow(options){
  if(options.referrerInfo){
      const params1 = Base64.decode(options.referrerInfo.extraData.urlParams);
      this.globalData.extraUrlData= JSON.parse(decodeURIComponent(params1));
  }
}
globalData:{
  extraUrlData:null
}

相关文章

网友评论

      本文标题:微信小程序对接外部小程序跳转传参

      本文链接:https://www.haomeiwen.com/subject/rtmoldtx.html