当我在Vue组件上执行格式化文档命令时。vue文件VSCode将所有单引号字符串替换为双引号字符串。

在我的具体情况下,该规则与要求单引号的electronic -vue lint配置冲突。

我没有安装更漂亮的扩展(没有更漂亮。singleQuote在我的设置)

如何定制VSCode来避免这种情况?


当前回答

你可以在settings.json中使用它

"javascript.preferences.quoteStyle": "single"

其他回答

对我来说唯一有效的方法是: 并且仅适用于Angular项目:

开始你的项目吧。”Editorconfig "文件,并粘贴'quote_type = single'。 希望这对你也有用。

我在vscode中也有同样的问题。只需在根目录中创建一个. pretierrc文件,并添加以下json。 对于单引号添加:

{
  "singleQuote": true
}

对于双引号添加:

  {
      "singleQuote": false
  }

对于像我这样的新手:

在顶部导航栏的菜单中:选择“文件->首选项->设置”。 在搜索文本框中,输入Quote 在下面的过滤列表中,寻找齿轮图标,并在它旁边-“Prettier”。点击复选框启用“更漂亮:单引号”

如果你使用的是YAML插件,它还有一个单引号/双引号选项,这让我很困惑。欢呼。

quote_type = single

将此添加到.editorconfig中

# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
quote_type = single