网页正文全文高:document.body.scrollHeight
网页可见区域高:document.body.clientHeight
网页被卷去的高:document.body.scrollTop
==》滚动条距离底部的高度=document.body.scrollHeight - document.body.scrollTop - document.body.clientHeight
mounted() {
this.init();
let listObj = document.querySelector(".van-radio-group"); //页面地址list的盒子
listObj.addEventListener("touchmove", () => {
let height =
listObj.scrollHeight - listObj.scrollTop - listObj.clientHeight;
console.log(height);
if (height < 110) {
if (this.loading || this.finished) return;
this.page += 1;
console.log("当前", this.page);
this.init();
}
});
},
init() {
if (this.loading || this.finished) return;
this.loading = true;
this.axios
.post("/api/address/index", { page: this.page })
.then((data) => {
if (data.length > 0) {
//bug1:十条以内结束
if (data.length < 10) {
this.finished = true;
}
data.forEach((item) => {
this.$set(item, "tel", item.phone);
this.$set(item, "id", item.address_id);
this.$set(
item,
"address",
item.province_name +
" " +
item.city_name +
" " +
item.district_name +
" " +
item.details
);
if (!this.source && item.status == 1) {
this.chosenAddressId = item.address_id;
}
});
this.list = this.list.concat(data);
this.loading = false;
} else {
this.finished = true;
}
});
},
//bug2:在手机上获取不到滚动条的位置,需要给外层盒子高度100vh,竖向可滚动
.address {
height: 100vh;
overflow-y: scroll;
.list {
height: 100vh;
overflow-y: scroll;
padding: 0 0 0 5px; //去掉原来的padding
.van-radio-group {
height: 92vh; //bug3:不够一屏时不能滚动,超出时滚动
overflow-y: scroll;
}
}
}
本文地址:https://blog.csdn.net/weixin_43848576/article/details/107563174
如对本文有疑问, 点击进行留言回复!!
selenium + ajax抓取英雄联盟全部英雄的详细信息及多线程保存全部皮肤图片到本地
网友评论