VUE实时监听滚动条高度

VUE实时监听滚动条高度

先看效果图
在这里插入图片描述
没设置高度100vh获取方式

mounted: function() {
	window.addEventListener('scroll',this.rollingheight,true)
},
methods: {
	rollingheight:function(e){
		console.log(window.pageYOffset)
	},
},

设置高度100vh获取方式 需要最外层的一个id

<template>
<div id="orderFullScreen" style="height:100vh;">
	
	要在最外层设置好id

</div>
</template>

mounted: function() {
	document.getElementById('orderFullScreen').addEventListener('scroll', this.handleScrollx,true)
},
methods: {
	 handleScrollx() {
	          console.log(document.getElementById('orderFullScreen').scrollTop)
	  },
},

有什么问题欢迎评论留言,我会及时回复你的

原创文章 75 获赞 87 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_43764578/article/details/104638366
今日推荐