微信小程序开发文档连接php
clickButton:function(){ var that = this; wx.request({ url: 'http://localhost:9096/admin.php/index/jj', method : 'POST', header: { 'content-type': 'application/x-www-form-urlencoded' }, data : {}, success: function (res) { //console.log(res.data); var t = this; var arr = new Array(); arr = res.data; console.log(typeof (res.data)); console.log(arr[0]); that.setData({ user: res.data }); } }) this.setData({ msg: "Hello World" }) }
关于this.setData函数设置绑定数据的问题,若是 在request请求函数外部能够直接使用,若是在其内部使用,会报异常。this不能在其直接使用须要在request请求函数外部小程序
定义一个变量【名字随意定义】,上面我定义的是一个that。微信小程序
<view wx:for = "{{user}}">{{item.username}}</view>