vscode保存時の自動フォーマットの問題を解決する3つの方法

最近、vscode で保存時に自動的にセミコロンが追加される問題があります (設定はそうではありません)。この問題は主にVeturプラグインの更新によって引き起こされます。次の設定を行う必要があります。

方法 1

1. プロジェクトの .vscode フォルダーの下に formatter.json ファイルを作成します (このファイルはJS-CSS-HTML Formatterを構成するために使用されます)
2. そのファイルに次のような必要な構成を記述します。

{
  "onSave": true,
  "javascript": {
    "indent_size": 2,
    "indent_char": " ",
    "eol": "auto",
    "preserve_newlines": true,
    "break_chained_methods": false,
    "max_preserve_newlines": 0,
    "space_in_paren": false,
    "space_in_empty_paren": false,
    "jslint_happy": false,
    "space_after_anon_function": false,
    "keep_array_indentation": false,
    "space_before_conditional": true,
    "unescape_strings": false,
    "wrap_line_length": 0,
    "e4x": false,
    "end_with_newline": true,
    "comma_first": false,
    "brace_style": "preserve-inline"
  },
  "css": {
    "indent_size": 2,
    "indentCharacter": " ",
    "indent_char": " ",
    "selector_separator_newline": true,
    "end_with_newline": true,
    "newline_between_rules": true,
    "eol": "\n"
  },
  "html": {
    "indent_inner_html": false,
    "end_with_newline": true,
    "indent_size": 2,
    "indent_char": " ",
    "indent_character": " "
  }
}

方法 2

vscode で、ファイル -> 設定 -> 設定の右側に文を追加します。

//用系统自己的设置
"vetur.format.defaultFormatter.js": "vscode-typescript"

方法 3

vscode で、ファイル -> 設定 -> 設定の右側に文を追加します。

//自动保存 这样他就不会触发保存时自动格式化
"files.autoSave": "afterDelay"

おすすめ

転載: blog.csdn.net/suifengqianxing/article/details/78533810