前端实现自定义滚动加载

39 阅读1分钟
		this.$nextTick(() => {
			this.$refs.ulDemo.addEventListener('scroll', () => {
				let clientHeight = this.$refs.ulDemo.clientHeight
				let scrollTop = this.$refs.ulDemo.scrollTop
				let scrollHeight = this.$refs.ulDemo.scrollHeight
				if (clientHeight + scrollTop === scrollHeight) {
					// 调用下拉触底的方法
					this.onReachBottom()
				}
			})
		})
	},
        method:{
        		onReachBottom() {
			let allTotal = this.searchForm.pageNum * this.searchForm.pageSize
			if (allTotal < this.total) {
				this.searchForm.pageNum++
				this.changeInput()
			} else {
				console.log('加载完毕')
			}
		},
        }