格式化配置
setting.json配置
{
// tab 大小为2个空格
"editor.tabSize": 2,
// 开启 vscode 文件路径导航
"breadcrumbs.enabled": true,
// prettier 设置强制单引号
"prettier.singleQuote": true,
"editor.inlayHints.enabled":"off",
"emmet.includeLanguages": {
"wxml": "html"
},
"minapp-vscode.disableAutoConfig": true,
"explorer.confirmDelete": true,
}
安装vetur插件,添加setting.json配置
{
"vetur.format.defaultFormatter.html": "js-beautify-html",
"vetur.format.defaultFormatter.js": "vscode-typescript",
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_attributes": "auto"
},
"prettier": {
"semi": false, //不加分号
"singleQuote": true //用单引号
}
},
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
}
配置.editorconfig文件
项目根目录下找到.editorconfig这个文件
# https://editorconfig.org
root = true # 根目录的配置文件,编辑器会由当前目录向上查找,如果找到 roor = true
的文件,则不再查找
[*] # 匹配所有的文件
indent_style = space # 空格缩进
indent_size = 2 # 缩进空格为2个
end_of_line = lf # 文件换行符是 linux 的 `\n`
charset = utf-8 # 文件编码是 utf-8
trim_trailing_whitespace = true # 不保留行末的空格
curly_bracket_next_line = false # 大括号不另起一行
spaces_around_operators = true # 运算符两遍都有空格
indent_brace_style = 1tbs # 条件语句格式是 1tbs
[*.js] # 对所有的 js 文件生效
quote_type = single # 字符串使用单引号
[*.{html,less,css,json}] # 对所有 html, less, css, json 文件生效
quote_type = double # 字符串使用双引号
[package.json] # 对 package.json 生效
indent_size = 2 # 使用2个空格缩进