跳至内容

vue/v-slot-style

强制执行 v-slot 指令样式

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

📖 规则详细信息

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

正在加载...

🔧 选项

json
{
  "vue/v-slot-style": ["error", {
    "atComponent": "shorthand" | "longform" | "v-slot",
    "default": "shorthand" | "longform" | "v-slot",
    "named": "shorthand" | "longform",
  }]
}
名称类型默认值描述
atComponent"shorthand" | "longform" | "v-slot""v-slot"自定义组件直接默认插槽的样式(例如 <my-component v-slot="">)。
default"shorthand" | "longform" | "v-slot""shorthand"模板包装器默认插槽的样式(例如 <template #default="">)。
named"shorthand" | "longform""shorthand"命名插槽的样式(例如 <template #named="">)。

每个值的意思

  • "shorthand" ... 使用 # 简写。例如 #default#named、...
  • "longform" ... 使用 v-slot: 指令符号。例如 v-slot:defaultv-slot:named、...
  • "v-slot" ... 使用 v-slot 而不带该参数。这比 #default 简写更短。

为了与类似的 vue/v-bind-stylevue/v-on-style 保持一致,也支持字符串选项。

  • ["error", "longform"] 等同于 ["error", { atComponent: "longform", default: "longform", named: "longform" }]
  • ["error", "shorthand"] 等同于 ["error", { atComponent: "shorthand", default: "shorthand", named: "shorthand" }]

"longform"

正在加载...

📚 进一步阅读

🚀 版本

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

🔍 实现