vue 上拉加载更多

var _this=this;
var goods_id = _this.$route.query.id;
var isscroll = true;
_this.$nextTick(() => {
var el = document.querySelector(".rating_cnt_scroll");
var offsetHeight = el.offsetHeight;
el.onscroll = () => {
var scrollTop = el.scrollTop;
var scrollHeight = el.scrollHeight;
if (offsetHeight + scrollTop - scrollHeight >= -1) {
if(isscroll==true){
isscroll = false;
var requestData = [];
_this.mountedPage++;
console.log(_this.mountedPage);
isscroll = false;
var data = {
goods_id: goods_id,
page: _this.mountedPage,
checkData: _this.$md5("caiegouinterface")
};
_this.$http.post(baseUrl + "/api/Goods/getEvaluate", data, {emulateJSON: true})
.then(res => {
if(res.body.code==200){
requestData = res.body.data.evaluate;
if (res.body.data.length == 0) {
//_this.page=1;
isscroll = true;
return false;
}
}
});
}
setTimeout(() => {
_this.evaluate = _this.evaluate.concat(requestData);
isscroll = true;
}, 100);
}

}
})

posted @ 2018-09-10 15:04  斯丢皮德曼  阅读(812)  评论(0编辑  收藏  举报