讯睿CMS问答:为什么小程序调用不出数据?

讯睿CMS问答:为什么小程序调用不出数据?

2025-01-11 XunRuiCMS Sincere

问题:

index.wxml

标题 {{item.title}}

图片地址{{item.thumb}}

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 () {

}

})

官方接口:https://www.jiangxiaohai.cn/index.php?c=api&m=data2&format=jsonp&auth=6d41236f9179ab62b5f378667302476c¶m=list%20action=module%20module=news%20order=updatetime%20num=10

使用2个接口,都调用不出数据,到底该如何调用数据啊?

答案:

点你的接口进去是有数据的,服务端有数据。。。说明客户端没有写好显示方法

【竹子工作室】1楼 但是我换一个其他的接口,又能显示别人的数据的

你接口里面根本没有返回results变量,你为什么要 result: res.data.results

换成: result: res.data

【王兴业】3楼 说实话,我也不懂啊,网上找的例子修改的。哈 数据显示了,谢谢!

感谢大家给我解决此问题,我已经完美的解决