vue 监听某div滚动条的滚动事件
监听此div , 定义ref<div class="productSec" ref="rightContent" @mousewheel="scrool">mounted: function(){//在mounted钩子函数绑定滚动条事件this.$refs.rightContent.addEventListener('scroll', this.scroo...
·
监听此div , 定义ref <div class="productSec" ref="rightContent" @mousewheel="scrool">
mounted: function(){
//在mounted钩子函数绑定滚动条事件
this.$refs.rightContent.addEventListener('scroll', this.scrool);
},
methods: {
scrool(){
console.log('===scrool===')
let scrolled = this.$refs.rightContent.scrollTop;
console.log(scrolled )
}
},
注:只写@mousewheel="scrool" 鼠标滚动事件,不能监听到:用鼠标拖动滚动条
更多推荐



所有评论(0)