用vue手腳架生成的項目直接修改時.vue文件後,保存編譯就報一大堆的錯,解決方法:
一問題:
因爲設置了eslint,如果你不想有規範的js代碼,可以重新初始化關掉eslint。Use ESLint to lint your code? (Y/n) 這一步選no
如果你想有良好的規範,其實錯誤已經很清晰,大多數就是縮進不規範,分號不需要等原因,很容易解決的。寫多了就成習慣了。
二、或在eslint中修改配置:
1 .禁止多個空行(no-multiple-empty-lines)
2. semi Extra semicolon(額外的分號)
3. Newline required at end of file but not found
4.Expect to indent the 2 spaces, but found that the 4
三、使用vue-cli腳手架構建了webpack項目,在開發過程中,Eslint驗證太嚴謹了,想通過設置將這驗證給關閉掉 ,操作如下:
在webpack.base.conf.js裏面刪掉下面:
preLoaders: [
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: [/node_modules/, /ignore_lib/]
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
exclude: [/node_modules/, /ignore_lib/]
}
]
或者不想進行校驗的文件就想上面一樣創建一個ignore_lib,然後全部丟進去。