聯(lián)系官方銷售客服
1835022288
028-61286886
index.wxml
<!--index.wxml-->
<block wx:for-items="{{result}}">
<view style="width:100%; height: 50rpx"></view>
<!--index默認為下標,item為每項-->
<text>標題 {{item.title}}</text>
<text>圖片地址{{item.thumb}}</text>
</block>
index.js 簡化接口
//index.js
//獲取應用實例
var app = getApp()
Page({
data: {
// text:"這是一個頁面"
result: []
},
onLoad: function () {
var that = this;
wx.request({
url: 'https://www.jiangxiaohai.cn/index.php?c=api&m=data2&auth=6d41236f9179ab62b5f378667302476c&function=dr_function_test¶m=list%20action=module%20module=news',
method: 'GET',
success: function (res) {
that.setData({
result: res.data.results
})
}
})
},
listenerButton: function () {
}
})
使用2個接口,都調用不出數(shù)據(jù),到底該如何調用數(shù)據(jù)???
點你的接口進去是有數(shù)據(jù)的,服務端有數(shù)據(jù)。。。說明客戶端沒有寫好顯示方法
【竹子工作室】1樓 但是我換一個其他的接口,又能顯示別人的數(shù)據(jù)的
你接口里面根本沒有返回results變量,你為什么要 result: res.data.results
換成: result: res.data
【王興業(yè)】3樓 說實話,我也不懂啊,網(wǎng)上找的例子修改的。哈 數(shù)據(jù)顯示了,謝謝!