之前一直用HBuilderX的内置浏览器里调试,今天写完了用手机扫码看效果,发现手机只能显示vue内容,接口传回来的数据都不显示。
求大佬解答!
var len = 0;
export default {
name: "tables1",
data() {
return {
key: 0,
totalPage: 1, // 统共页数,默认为1
currentPage: 1, //当前页数 ,默认为1
pageSize: 10, // 每页显示数量
currentPageData: [] //当前页显示内容
}
},
onLoad: function(options) {
let that = this;
//调用数据库接口获得查询结果
uni.request({
url: 'http://localhost:8080/AssetAdmin/api/login/getattendance?userid=123&startdtime=2020-7-1&enddtime=2020-7-20', //数据库接口
method: 'GET',
success: function(res_post) {
console.log(res_post);
var n;
for (n in res_post.data) {
if (res_post.data.hasOwnProperty(n)) {
len++;
}
}
// 计算一共有几页
that.$data.totalPage = Math.ceil(len / that.$data.pageSize);
console.log(that.$data.totalPage);
// 计算得0时设置为1
that.$data.totalPage = that.$data.totalPage == 0 ? 1 : that.$data.totalPage;
that.$data.currentPageData = res_post.data.slice(0, 10);
},
});
},