1.配置script默认缩进
{
"singleQuote": true,
"semi": false,
"printWidth": 120,
"trailingComma": "none",
"arrowParens": "avoid",
"bracketSpacing": true,
"tabWidth": 4,
"useTabs": false,
"vueIndentScriptAndStyle": true// 在Vue文件中,此设置决定`<script>`和`<style>`标签内的代码是否缩进。
}
2.常用配置
{
"printWidth": 220, // 此设置定义了每行代码的最大字符数。若代码行超出此长度,格式化工具会尝试将其拆分为多行。
"tabWidth": 2, // 此设置指定一个制表符(tab)的宽度,即它等同于多少个空格。这有助于确保代码缩进的一致性。
"useTabs": true, // 此设置决定是否使用制表符进行缩进。若设为true,则使用制表符;反之,则使用空格。
"semi": true, // 此设置决定是否在语句末尾添加分号。若设为false,则不添加。
"singleQuote": false, // 此设置决定是否优先使用单引号。若设为true,则字符串默认使用单引号。
"quoteProps": "as-needed", // 此设置定义对象属性是否添加引号。设为"as-needed"时,仅在属性名不是有效标识符时添加引号。
"trailingComma": "none", // 此设置决定在多行时是否添加尾随逗号。设为"none"时,不添加尾随逗号。
"bracketSpacing": true, // 此设置决定在对象字面量的括号间是否添加空格,例如:`{ foo: bar }`。
"jsxBracketSameLine": false, // 在JSX中,若表达式跨多行,此设置决定`>`的位置。设为false时,`>`位于新行。
"arrowParens": "avoid", // 此设置决定单参数箭头函数的参数是否使用圆括号。设为"avoid"时,尽可能不使用圆括号。
"endOfLine": "lf", // 此设置定义行尾使用的字符。设为"lf"时,使用LF(换行符)作为行尾字符。
"jsxSingleQuote": false, // 在JSX中,此设置决定是否使用单引号。设为false时,默认使用双引号。
"vueIndentScriptAndStyle": true // 在Vue文件中,此设置决定`<script>`和`<style>`标签内的代码是否缩进。
}