Install prettier
The first step is to set up vetur
Click settings
Search vetur
Find formatter js and select prettier ⚠️This step is very important. If it is not prettier, your settings below will have no effect.
Find where settings.json is set
turn up
"prettier": {
//间隔修改为2个空格
"tabSize": 2,
//设置分号
"semi": false,
//双引号变成单引号
"singleQuote": true,
//禁止随时添加逗号
"trailingComma": "none"
}
Set as needed and click Use.. to format the document
By selecting this, we can directly change the double quotes into single quotes when formatting.
For more settings, please check the official website documentation
Options · Prettier Chinese website
Add a space after the function name
"vetur.format.defaultFormatter.js": "vscode-typescript",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,