vue-scroller不兼容PC端的鼠标滚轮上划和下滑,此时要监听鼠标滚轮事件,mousewheel,在Vue中引用即可
created() {
this.init()
}
methods: {
init(){
let _this = this //此this指向的是vue
window.onmousewheel = function (e) {
if (e.wheelDelta < 0) {
_this.$refs.scrollerBottom && (_this.$refs.scrollerBottom.scrollBy(0, 30, false));
//避免ref中不存在scrollerBottom
} else {
_this.$refs.scrollerBottom && (_this.$refs.scrollerBottom.scrollBy(0, -30, false));
}
}
参考原文,感谢博主分享
https://www.cnblogs.com/cjh1111/p/7363836.html