当你在vue项目开发中使用了better-scroll的手机插件时候,浏览器将不进行滚动,而变成了滑动,这时候电脑浏览器可以用@click点击绑定事件,而在手机测试时,将没有反应。
原因是:better-scroll 默认会阻止浏览器的原生 click 事件。当设置为 true,better-scroll 会派发一个 click 事件,我们会给派发的 event 参数加一个私有属性 _constructed,值为 true。
代码展示方法:
html代码:
<template>
<div class="list" ref="wrapper">
...
...
...
</div>
</template>
js代码:
mounted () {
const options = {
scrollY: false, // 因为scrollY默认为true,其实可以省略
scrollX: true,
mouseWheel: true,
click: true,
taps: true
}
this.scroll = new Bscroll(this.$refs.wrapper, options)
}
}