跳至内容

vue/no-restricted-v-bind

禁止在 v-bind 中使用特定参数

📖 规则详情

此规则允许您指定在应用程序中不想使用的 v-bind 参数名称。

🔧 选项

此规则接受字符串列表,其中每个字符串都是要限制的参数名称或模式。

json
{
  "vue/no-restricted-v-bind": ["error", "/^v-/", "foo", "bar"]
}
正在加载...

默认情况下,设置了 '/^v-/'。这可以防止将指令误认为是指令。

正在加载...

或者,该规则也接受对象。

json
{
  "vue/no-restricted-v-bind": [
    "error",
    {
      "argument": "/^v-/",
      "message": "Using `:v-xxx` is not allowed. Instead, remove `:` and use it as directive."
    },
    {
      "argument": "foo",
      "message": "Use \"v-bind:x\" instead."
    },
    {
      "argument": "bar",
      "message": "\":bar\" is deprecated."
    }
  ]
}

可以为对象指定以下属性。

  • argument ... 指定参数名称或模式,或 null。如果指定了 null,则匹配 v-bind=
  • modifiers ... 指定修饰符名称的数组。如果指定,则只有在使用指定的修饰符时才会报告。
  • element ... 指定元素名称或模式。如果指定,则只有在对指定元素使用时才会报告。
  • message ... 指定可选的自定义消息。

{ "argument": "foo", "modifiers": ["prop"] }

正在加载...

{ "argument": "foo", "element": "MyButton" }

正在加载...

🚀 版本

此规则是在 eslint-plugin-vue v7.0.0 中引入的

🔍 实现