一、使用babel-plugin-transform-remove-console
插件
1 cnpm install babel-plugin-transform-remove-console --save-dev
二、在babel.consig.js中配置
const plugins = ["@vue/babel-plugin-transform-vue-jsx"]; // 生产环境移除console if(process.env.NODE_ENV === 'production') { plugins.push("transform-remove-console") } module.exports = { plugins: plugins, presets: [ '@vue/cli-plugin-babel/preset' ] }