vue touchmove无法触发


问题说明

<div class="info_box" @touchstart="start" @touchmove='move' @touchend='end'></div>

touchstart touchend都可以触发 touchmove不可触发

问题解决

在start(e){}方法里打印e.cancelable e.defaultPrevented

start (e) {
  console.log(e.cancelable)
  console.log(e.defaultPrevented)
}

结果为 true false ,表明没有禁用默认事件
在start中添加e.preventDefault(),禁用默认事件
问题解决

start (e) {
  e.preventDefault()
}

然后会报错
应用 CSS 属性 touch-action: none; 这样任何触摸事件都不会产生默认行为,但是 touch 事件照样触发

参考:https://blog.csdn.net/lijingshan34/article/details/88350456


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM