1.去除错误提示:使用 Vue.config.silent。
2.去除 console 控制台输出信息:使用 babel-plugin-transform-remove-console 插件。
1)安装babel-plugin-transform-remove-console插件:
npm install babel-plugin-transform-remove-console --save-dev
2)在babel.config.js中配置插件信息:
const productPlugins = []
if(process.env.NODE_ENV === 'production'){
productPlugins.push("transform-remove-console")
}
module.exports = {
"presets": [
"@vue/app"
],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
],
...productPlugins
]
}