vue

vue项目去除浏览器控制台的信息

2022-10-13  本文已影响0人  陶菇凉

1.问题描述:
vue项目中使用ElementUI的表单form校验单的时候,出现以下警告:
[Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive.
虽然他不会直接影响项目出现报错或者无法正常运行,但是这系列警告的存在就会为以后项目运行出现未知问题埋下隐患。

// 安装插件
npm install -S default-passive-events
// 在main.js引入
import 'default-passive-events'

2.浏览器会显示此类的信息
You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html
-解决办法:
要写在vue.js引入文件之后

<script>
      Vue.config.productionTip = false
    </script>

若还没有则在vue.config.js中配置

configureWebpack: {
    optimization: {
      minimizer: [new TerserPlugin({ terserOptions: { compress: { drop_console: true } 
    } })]
    },
}
上一篇下一篇

猜你喜欢

热点阅读