小程序获取二维码的场景值问题
发布于 6 年前 作者 xuchao 12462 次浏览 来自 问答

通过接口传参自定义scene去生成小程序二维码,官方说扫描二维码获取场景值的方式为:

// 这是首页的 js
Page({
  onLoad: function(options) {
    // options 中的 scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene
    var scene = decodeURIComponent(options.scene)
  }
})

但是,实际上我们做了好了生成二维码功能,扫描二维码之后,从 options.scene 中获取的是微信提供的默认场景值(比如1047:扫描小程序码),我们自定义的scene需要去 options.query.scene 获取

回到顶部