先将vscode升级到最新,卸载vetur,安装volar(vue official)。
再安装vscode的eslint。
在vue项目下创建.eslintrc.js
配置如下
module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true
},
extends: [
'eslint:recommended',
'plugin:vue/vue3-recommended',
],
plugins: [
'vue',
],
globals: {
defineProps: "readonly",
defineEmits: "readonly",
defineExpose: "readonly",
withDefaults: "readonly",
},
rules: {
'vue/multi-word-component-names': 'off', // 接触文件名限制
"vue/html-self-closing": ["error", { // 闭合标签验证逻辑处理
"html": {
"void": "always",
"normal": "never",
"component": "always"
},
"svg": "always",
"math": "always"
}]
}
};