[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive.


1.[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive.

兩個方案:
(1)注冊處理函數時,用如下方式,明確聲明為不是被動的
window.addEventListener('touchmove', func, { passive: false })

(2)應用 CSS 屬性 touch-action: none; 這樣任何觸摸事件都不會產生默認行為,但是 touch 事件照樣觸發。
touch-action 還有很多選項,詳細請參考touch-action


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM