問題說明
<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