zoukankan      html  css  js  c++  java
  • 小程序 服务器端调用接口获取小程序太阳码 前端接收问题

     

    获取 scene 值

    scene 字段的值会作为 query 参数传递给小程序/小游戏。用户扫描该码进入小程序/小游戏后,开发者可以获取到二维码中的 scene 值,再做处理逻辑。

    调试阶段可以使用开发工具的条件编译自定义参数 scene=xxxx 进行模拟,开发工具模拟时的 scene 的参数值需要进行 encodeURIComponent

    小程序(记得解码)

    Page({
      onLoad (options) {
        // scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene
        const scene = decodeURIComponent(options.scene)
       //split() 方法用于把一个字符串分割成字符串数组。如果一个参数是scene='id=1'多个用&连接scene='id=1&good=1322'  最大32字符,不会太多参数
      一个参数时候 id=scene.split('=')[1]
      多个参数时候 id=(scene.split('&')[0]).split('=')[1]   this.setData({     id: id   } })

      



  • 相关阅读:
    Dangling Javadoc comment
    IntelliJ IDEA :Error(1, 1) java 非法字符 'ufeff'
    什么是webhook
    智能DNS
    filebeat 乱码
    windows,交换机syslog收集
    Rsyslog
    ntp
    centos7 -lvm卷组
    nginx安装
  • 原文地址:https://www.cnblogs.com/yaoling/p/13650337.html
Copyright © 2011-2022 走看看