vue中使用better-scroll @click事件执行两次,求各位帮忙解决

vue中使用better-scroll @click事件执行两次,请问怎么解决

潇潇雨雨
浏览 1821回答 3
3回答

湖上湖

同出过该问题,备注一下:一开始以为跟项目中的fastclick冲突,后确认非该原因导致。官网Demo也没有类似问题,最后暂时改为@touchstart+@touchend.stop.prevent模拟@click。示例代码:<template>&nbsp; <button @touchstart="start($event)" @touchend.stop.prevent="stop($event)">Test</button></template><script>&nbsp; export default {&nbsp; &nbsp; methods: {&nbsp; &nbsp; &nbsp; start ($event) {&nbsp; &nbsp; &nbsp; &nbsp; this.startY = $event.touches[0].pageY&nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; stop ($event) {&nbsp; &nbsp; &nbsp; &nbsp; const moving = Math.abs($event.changedTouches[0].pageY - this.startY)&nbsp; &nbsp; &nbsp; &nbsp; if (moving > 20) return&nbsp; &nbsp; &nbsp; &nbsp; this.startY = 0&nbsp; &nbsp; &nbsp; &nbsp; console.log('click')&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; }</script>

慕妹3242003

@click.native

萧十郎

问题已解决 楼上方法可行
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript