一個使用vue cli 3.2建立的項目,建立時未開啓 lintOnSave,後來但願開啓並設置爲 lintOnSave: 'error',但配置不生效。vue
解決方法1:新建立項目(此時vue cli 版本爲 3.4)並開啓 lintOnSave,而後刪除其中全部文件,將舊有項目全部代碼(包括node_modules)移動到新項目文件夾,發現lintOnSave報錯頁面提示有。node
解決方法2:在 vue.config.js 中配置:webpack
module.exports = { devServer: { overlay: { warnings: true, errors: true } }, lintOnSave: 'error', chainWebpack: config => { config.module.rule('eslint').use('eslint-loader').loader('eslint-loader').tap(opt => { opt.emitWarning = opt.emitError = opt.failOnWarning = opt.failOnError = true; return opt; }); } };
參考:【eslint-loader:Errors and Warning】web