vscode升级到1.19.2后,格式化出现问题,js函数括号前没空格,vue文件的html代码不被格式化

user setting 的配置如下:

{
  "workbench.colorTheme": "Monokai",
  "editor.matchBrackets": false,
  "workbench.iconTheme": "vscode-icons",
  "gitlens.advanced.messages": {
    "suppressCommitHasNoPreviousCommitWarning": false,
    "suppressCommitNotFoundWarning": false,
    "suppressFileNotUnderSourceControlWarning": false,
    "suppressGitVersionWarning": false,
    "suppressLineUncommittedWarning": false,
    "suppressNoRepositoryWarning": false,
    "suppressUpdateNotice": false,
    "suppressWelcomeNotice": true
  },
  "files.associations": {
    "*.vue": "vue"
  },
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "html",
    "vue",
    {
      "language": "vue",
      "autoFix": true
    }
  ],
  "eslint.autoFixOnSave": true,
  "editor.tabSize": 2,
  "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
  "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
  "typescript.format.insertSpaceBeforeFunctionParenthesis": true,
  "prettier.singleQuote": true,
  "prettier.trailingComma": "none",
  "prettier.semi": false,
  "prettier.useTabs": false,
  "prettier.tabWidth": 2,
  "vetur.format.defaultFormatter.js": "prettier",
  "vetur.format.defaultFormatter.html": "js-beautify-html"
}

之前格式化一直没问题,vscode更新之后,格式化后,javascript函数的小括号前的空格被去掉,并且vue文件template里的代码根本不被格式化。

阅读 16.5k
3 个回答

使用vsc自带的ts格式化,配置以下内容:

"vetur.format.defaultFormatter.js": "vscode-typescript"
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,

楼主解决了吗?
我这也遇到了同样的问题,之前配置的vetur、prettier现在也不起作用了

推荐问题
logo
Microsoft
子站问答
访问
宣传栏