此配置支持 CSS、HTML、JS 和 Vue 等文件的格式化
一、安装插件:
Prettier 、Eslint、Vetur
ESlint: javascript代码检测工具,可以配置每次保存时格式化js
Prettier - Code formatter: 只关注格式化,并不具有eslint检查语法等能力,只关心格式化文件(最大长度、混合标签和空格、引用样式等),包括JavaScript · Flow · TypeScript · CSS · SCSS · Less · JSX · Vue · GraphQL · JSON · Markdown
vetur: 可以格式化html、标准css(有分号 、大括号的那种)、标准js(有分号 、双引号的那种)、vue文件
二、setting.josn配置
文件-首选项-设置-在setting.josn中编辑
{
"editor.fontSize": 15,
"workbench.editor.enablePreview": false,
"editor.formatOnSave": true,
"files.autoSave": "off",
"editor.wordWrap": "on",
"editor.tabSize": 2,
"editor.tokenColorCustomizations": {},
"prettier.singleQuote": true,
"prettier.trailingComma": "es5",
"javascript.implicitProjectConfig.experimentalDecorators": true,
"files.eol": "\n",
"workbench.activityBar.visible": true,
"window.menuBarVisibility": "default",
"javascript.updateImportsOnFileMove.enabled": "never",
"vsicons.dontShowNewVersionMessage": true,
"window.zoomLevel": 0,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[less]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"diffEditor.ignoreTrimWhitespace": false,
"editor.codeActionsOnSave": null
}