Skip to content

vue/html-quotes

强制使用 HTML 属性的引号样式

  • ⚙️ 此规则包含在 "plugin:vue/strongly-recommended"*.configs["flat/strongly-recommended"]"plugin:vue/vue2-strongly-recommended"*.configs["flat/vue2-strongly-recommended"]"plugin:vue/recommended"*.configs["flat/recommended"]"plugin:vue/vue2-recommended"*.configs["flat/vue2-recommended"] 中。
  • 🔧命令行 上的 --fix 选项可以自动修复此规则报告的一些问题。

    ¥🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

你可以从以下位置选择 HTML 属性的引号:

¥You can choose quotes of HTML attributes from:

  • 双引号:<div class="foo">

    ¥Double quotes: <div class="foo">

  • 单引号:<div class='foo'>

    ¥Single quotes: <div class='foo'>

  • 无引号:<div class=foo>

    ¥No quotes: <div class=foo>

此规则强制使用 HTML 属性的引号样式。

¥This rule enforces the quotes style of HTML attributes.

📖 规则详情

如果属性的引号与配置的引号不同,则此规则报告属性的引号。

¥This rule reports the quotes of attributes if it is different to configured quotes.

Now loading...

🔧选项

¥🔧 Options

默认值设置为 double

¥Default is set to double.

json
{
  "vue/html-quotes": [ "error", "double" | "single", { "avoidEscape": false } ]
}

字符串选项:

¥String option:

  • "double"(默认)...要求双引号。

    ¥"double" (default) ... requires double quotes.

  • "single" ...需要单引号。

    ¥"single" ... requires single quotes.

对象选项:

¥Object option:

  • avoidEscape ...如果是 true,则允许字符串使用单引号或双引号,只要字符串包含必须转义的引号即可。

    ¥avoidEscape ... If true, allows strings to use single-quotes or double-quotes so long as the string contains a quote that would have to be escaped otherwise.

"single"

Now loading...

"double", { "avoidEscape": true }

Now loading...

📚扩展阅读

¥📚 Further Reading

🚀版本

¥🚀 Version

此规则在 eslint-plugin-vue v3.0.0 中引入

¥This rule was introduced in eslint-plugin-vue v3.0.0

🔍代码实现

¥🔍 Implementation

eslint-plugin-vue v10.0 中文网 - 粤ICP备13048890号