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

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 } 
    } })]
    },
}
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容