获取微信小程序生成指定页面并且带有参数的太阳码的参数

微信小程序生成指定页面并且带有参数的太阳码,扫码进入该页面拿不到太阳码里边带的参数,记录一下

解决办法:

微信提供encodeURIComponent方法获取

 

文档:

https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.getUnlimited.html


实例:

onLoad:function(query) {

    let that = this;

    if (query.scene){

      const scene = decodeURIComponent(query.scene)
      console.log(sence)  // 22&shopname

      var id = scene.split('&')[0]

      var shopName = scene.split('&')[1]

      that.setData({

        sid: id,

        shopName: shopName

      })

    }

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章