移动端报错: Unable to preventDefault inside passive event listener due to target being treated as passive的解决方案

时间:2018-11-02 17:20:20   收藏:0   阅读:1925

 

在做react移动端项目的时候,连续点击底部导航,浏览器就会报Unable to preventDefault inside passive event listener due to target being treated as passive的错:

 

技术分享图片

 

解决方案: 给html加上CSS 属性 touch-action: none; 这样任何触摸事件都不会产生默认行为,但是 touch 事件照样触发。

html {
    font-size: 6.666667vw;
    overflow-x: hidden;
    height: 100%;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    background-color: $color-base-background;
    color: $color-black;
}

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!