1-vscode 中装置eslint
2-在vue我的项目中开启esLint检测, 在vue.config.js文件中
lintOnSave: true,
3-上面是我vscode的配置文件settings.json文件
{ // VScode主题配置 "editor.tabSize": 2, "eslint.autoFixOnSave": true, // 每次保留的时候将代码按eslint格局进行修复 "editor.lineHeight": 24, "editor.renderLineHighlight": "none", "editor.renderWhitespace": "none", "editor.fontFamily": "Consolas", "editor.fontSize": 13, "editor.cursorBlinking": "smooth", "editor.multiCursorModifier": "ctrlCmd", "editor.formatOnSave": true, "editor.quickSuggestions": { "other": true, "comments": true, "strings": false }, "prettier.semi": true, //去掉代码结尾的分号 "prettier.singleQuote": false, //应用单引号代替双引号 "javascript.format.insertSpaceBeforeFunctionParenthesis": true, //让函数(名)和前面的括号之间加个空格 "vetur.format.defaultFormatter.html": "js-beautify-html", //格式化.vue中html "vetur.format.defaultFormatterOptions": { "js-beautify-html": { "wrap_attributes": "force-aligned" //属性强制折行对齐 } }, "eslint.validate": [ "javascript", "javascriptreact", "html", "vue", ], "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, "debug.console.fontSize": 14, "git.path": "F:/Program Files/Git/bin/git.exe", //git门路的配置}