// 绑定事件 
 <template  @scroll.native="getScroll" ></template>
	//method 中定义
 getScroll(event) {
 		// 获取滚动条离顶部的距离
		let top = event.target.scrollTop;
 		console.log(top)
		// 滚动条距离底部的距离scrollBottom
		let scrollBottom =
			event.target.scrollHeight -
			event.target.scrollTop -
			event.target.clientHeight;
		console.log(scrollBottom )
 },
  // mounted中
  mounted(){
 	 window.addEventListener('scroll', this.getScroll,true)
  }
	
Logo

Vue社区为您提供最前沿的新闻资讯和知识内容

更多推荐