问题
自动格式化时,在最前面加了“|”
解决
修改settings.json为:
{
"security.workspace.trust.untrustedFiles": "open",
"prettier.singleQuote": true,
"html.completion.attributeDefaultValue": "singlequotes",
"prettier.jsxSingleQuote": true,
"diffEditor.ignoreTrimWhitespace": false,
"files.eol": "\n",
"github.copilot.editor.enableAutoCompletions": true,
"eslint.codeActionsOnSave.rules": null,
"typescript.updateImportsOnFileMove.enabled": "always",
"javascript.updateImportsOnFileMove.enabled": "always",
"eslint.alwaysShowStatus": true,
"files.associations": {
"*.ts": "typescript"
},
"eslint.enable": true, // eslint开启
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
//针对共用的语言如JS、TS和JSX关闭文件保存自动格式化功能,通过eslint来做这件事
"[javascript]": {
"editor.formatOnSave": false
},
"[javascriptreact]": {
"editor.formatOnSave": false
},
"[typescript]": {
"editor.formatOnSave": false
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"vue.server.hybridMode": "typeScriptPluginOnly"
}
js和ts文件不用prettier来自动格式化,而是使用eslint