首先设置vscode的setting.json
{
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
{
"language": "vue",
"autoFix": true
},
"html",
"vue"
],
// #每次保存的时候自动格式化
"editor.formatOnSave": true,
"vetur.format.defaultFormatter.js": "prettier",
"vetur.format.defaultFormatterOptions": {
"prettier": {
// Prettier option here
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
},
"files.autoSave": "onFocusChange"
}
其次安装vetur,eslint插件
安装eslint-plugin-vue
yarn add eslint-plugin-vue --dev
更改.eslinttrc.js 添加vue选项