vue 代码格式化需要下载的插件有 Vetur,ESLint,Beautify.
配置 Vue 代码格式化
在首选项 -- 设置中 settings.json, 将设置更改为
- "editor.formatOnSave": true,
- "eslint.autoFixOnSave": true,
- // 添加 vue 支持
- "eslint.validate": [
- "javascript",
- "javascriptreact",
- {
- "language": "vue",
- "autoFix": true
- }
- ],
- "editor.detectIndentation": false,
- "vetur.format.defaultFormatter.js": "none",
- "vetur.format.defaultFormatter.html": "js-beautify-html"
可以通过 "editor.tabSize": 2 设置缩进空格数等等
来源: http://www.qdfuns.com/article/50494/ea699bd0fafe27e2a50960de86ab021f.html