先安裝插件ESLint,后面在設置setting.json中配置加入代碼:
{
"files.autoSave": "afterDelay",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"git.path": "E:/git/Git/bin/git.exe",
"window.zoomLevel": 0,
"editor.formatOnSave": false,
"eslint.options":{
"extensins":[
".js",
".vue"
]
},
"eslint.validate": [
"javascript",
{
"language": "html",
"autoFix": true
},
{
"language": "vue",
"autoFix": true
},
],
"eslint.autoFixOnSave": true,
}
項目中安裝eslint校驗后軟件配置好后保存時會自動格式化代碼,多按保存,每次會處理一部分校驗代碼,最后有報紅的單獨處理即可