收藏
回答

微信小程序下拉加载为什么重复发送请求

哪位大神帮我看看这是为什么?

以下是我的下拉加载的代码,本机测试是好的,但是真机调试就会出现重复的数据

//下拉加载

lower: function (e) {

let that=this;

var i = this.data.i;

that.setData({

page: ++i

})

console.log(i, '下拉加载')

wx.request({

url: 'https://www.nxztsckj.com/Max/php/wxxcxAPI/demo.php',

data: {

types: "getJobList",

userId: app.globalData.unionId,

ptType: '',

ptPosReq: '',

ptCity: that.data.ptCity,

ptCountry: that.data.ptCountry,

page: that.data.page,

num: that.data.num,

ptName: that.data.inputValue,

},

header: {

'content-type': 'application/json' // 默认值

},

success: function (res) {

// console.log(res.data);

var result = JSON.parse(res.data).obj;

console.log(result);

if (result.length > 0) {

for (let i = 0; i < result.length; i++) {

let datess = new Date(result[i].ptPublishTime);

result[i].ptPublishTime = util.formatTime(datess).split(" ")[0]

}

let hasMore = true;

if (result.length < that.data.num) {

hasMore = false;

}

that.setData({

dataList: that.data.dataList.concat(result),

ifdataList: true,

i:i,

hasMore: hasMore

})

} else {

that.setData({

hasMore: false

})

}

}

})

wx.stopPullDownRefresh();

},


真机测试的结果如下:


最后一次编辑于  2018-11-07
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容