test.js
代码如下:
makeRequest: function (e) {
var self = this
wx.request({
url: \'http://lt.com/home/index/test\',//php方法里返回json数据格式(ajax)
method: \'GET\',
header: {
\'content-type\': \'application/json\'
},
success: function (result) {
console.log(result.data)
self.setData({
con: result.data,
hasTest: true
})
}
})
}
test.xml
代码如下:
<view class="btn-area">
<!--按钮点击 -->
<button wx:if="{{!hasTest && canIUse}}" bindtap="makeRequest"
open-type="request" bindgetuserinfo="request"
type="primary" disabled="{{buttonDisabled}}" loading="{ {loading}}">request</button>
<!-- 数组遍历 -->
<block wx:for="{{con}}">
<image bindtap="bindViewTap" mode="widthFix" class="userinfo-avatar" src="http://www.sctlmzs.com/Public/Uploads/{{item.img_path}}" background-size="cover"></image>
</block>
</view>
效果如下: