Skip to content

vue/v-bind-style

强制 v-bind 指令样式

  • ⚙️ 此规则包含在 "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.

📖 规则详情

此规则强制执行 v-bind 指令样式,你应该使用简写或长格式。

¥This rule enforces v-bind directive style which you should use shorthand or long form.

Now loading...

🔧选项

¥🔧 Options

json
{
  "vue/v-bind-style": ["error", "shorthand" | "longform", {
    "sameNameShorthand": "ignore" | "always" | "never"
  }]
}
  • "shorthand"(默认)...需要使用简写。

    ¥"shorthand" (default) ... requires using shorthand.

  • "longform" ...需要使用长格式。

    ¥"longform" ... requires using long form.

  • sameNameShorthand ...强制 v-bind 同名简写样式(Vue 3.4+)。

    ¥sameNameShorthand ... enforce the v-bind same-name shorthand style (Vue 3.4+).

    • "ignore"(默认)...忽略同名简写样式。

      ¥"ignore" (default) ... ignores the same-name shorthand style.

    • "always" ...尽可能强制使用同名简写。

      ¥"always" ... always enforces same-name shorthand where possible.

    • "never" ...尽可能禁止使用同名简写。

      ¥"never" ... always disallow same-name shorthand where possible.

"longform"

Now loading...

{ "sameNameShorthand": "always" }

Now loading...

{ "sameNameShorthand": "never" }

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号