小程序js文件
~~~
Page({
onLoad: function () {
var that = this;
wx.request({
url: 'http://127.0.0.1:8000/tp/',
method: 'GET',
success: function (res) {
that.setData({
result: res.data
})
}
})
}
})
~~~
小程序wxml文件
~~~
<!-- wx:for 循環數據 {{已item.}}格式傳輸 -->
<block wx:for-items="{{result}}">
<view style="width:100%; height: 50rpx"></view>
<!--index默認為下標,item為每項-->
<text>第{{index}}條數據 {{item.tetle}}</text>
<image src='{{item.url}}'></image>
</block>
~~~