overflow-x: auto;
overflow-y: auto;
overflow: auto;
- 当复杂case中scroll出现问题时,可以在容器中加一个<随意大小>子元素,然后,由子元素容纳其他内容。
element.scrollTop = 0
element.scrollTop = element.scrollHeight - element.clientHeight
element.scrollHeight - element.scrollTop === element.clientHeight
window.onscroll = () => {
if (!this.isLoading && this.isCanLoad) {
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
let windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
if (scrollHeight - scrollTop - windowHeight < 30) {
this.loadMore();
}
}
};