小程序框架(内容中统一叫标签)总结

组件:

1、button属性,如;<button open-type="getUserInfo" bindgetuserinfo="onGotUserInfo">调用微信的接口</button>

  open-type :  微信开放能力  ;  这里的值必须是微信提供的,及对应微信提供的能力。有  

            launchApp——打开APP、getPhoneNumber——获取用户手机号、getUserInfo——获取用户信息   等几种

  bindgetuserinfo :这个属性必须要和open-type对应,button几个 bind前缀的属性是和 open-type对应的,具体的看 官方文档  

(个人)微信标签中以bind开头的属性,值都是绑定事件函数的。

事件:官方文档

 http://www.jb51.net/article/94936.htm

  bindtap    点击事件

 

微信API:

1、http请求:

  GET请求:

wx.request({
  url: 'test.php', //仅为示例,并非真实的接口地址
  data: {
     x: '' ,
     y: ''
  },
  header: {
      'content-type': 'application/json' // 默认值
  },
  success: function(res) {
    console.log(res.data)
  }
})
View Code

  POST请求:

2、js中设置和获取data中的数据  参考:https://blog.csdn.net/chq1988/article/details/74625741/

  区别于vue中,获取时,直接this.name,获取不到data里面的数据,必须 this.data.name

  setData()方法  :  https://www.cnblogs.com/strong-FE/p/7117945.html

原文地址:https://www.cnblogs.com/wfblog/p/9151319.html