data: {
baidu: null
},
onLoad: function (options) {
var refs = this;
wx.request({
url: 'https://zhidao.baidu.com/question/api/recommend?t=1532415684126',
method: "GET",
success: function (res) {
refs.setData({baidu: res.data})
},
fail: function () {
console.log("接口调用失败");
}
})
},
<view>
<view style="margin-bottom: 30rpx" wx:for="{{ baidu.list }}" wx:key="{{ index }}">
<image src="{{ item.avatar }}" style="width:60rpx;height:60rpx;"></image>
<text style="font-size:37rpx">{{ item.uname }}:</text>
<text style="font-size:27rpx; color:#ccc;">{{ item.createTime }}</text>
<view>
<text>{{ item.title }}</text>
</view>
</view>
<view wx:for="{{ baidu.reward }}" wx:key="{{ index }}">
<image src="{{ item.imgUrl }}" style="width:100rpx;height:100rpx;"></image>
</view>
</view>