pc端vue 滚动到底部翻页 效果,具体内容如下所示:
html:
【{ {item.code||item.name}}】
{ {item.name}}
js:
先写滚动事件
handleScroll(){
let scrollTop = this.$refs.scrollTopList.scrollTop,
clientHeight = this.$refs.scrollTopList.clientHeight,
scrollHeight = this.$refs.scrollTopList.scrollHeight,
height = 50; //根据项目实际定义
if(scrollTop +clientHeight >= scrollHeight - height){
if(this.pageSize > this.total){
return false
}else{
this.pageSize = this.pageSize +10 //显示条数新增
this.getpageList() //请求列表list 接口方法
}
}else{
return false
}
},
method中写节流函数
throttle(func, wait) {
let lastTime = null
let timeout
return () => {
let context = this;
let now = new Date();
let arg = arguments;
if (now - lastTime - wait > 0) {
if (timeout) {
clearTimeout(timeout)