Appearance
vue/no-restricted-v-bind
禁止在
v-bind
中禁止特定参数¥disallow specific argument in
v-bind
📖 规则详情
此规则允许你指定你不想在应用中使用的 v-bind
参数名称。
¥This rule allows you to specify v-bind
argument names that you don't want to use in your application.
🔧选项
¥🔧 Options
此规则采用字符串列表,其中每个字符串都是要限制的参数名称或模式:
¥This rule takes a list of strings, where each string is a argument name or pattern to be restricted:
json
{
"vue/no-restricted-v-bind": ["error", "/^v-/", "foo", "bar"]
}
默认情况下,设置 '/^v-/'
。这可以防止本应是指令的错误。
¥By default, '/^v-/'
is set. This prevents mistakes intended to be directives.
或者,该规则也接受对象。
¥Alternatively, the rule also accepts objects.
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."
}
]
}
可以为对象指定以下属性。
¥The following properties can be specified for the object.
argument
...指定参数名称或模式或null
。如果指定了null
,则与v-bind=
匹配。¥
argument
... Specify the argument name or pattern ornull
. Ifnull
is specified, it matchesv-bind=
.modifiers
...指定修饰符名称的数组。如果指定,则仅在使用指定的修饰符时才会报告。¥
modifiers
... Specifies an array of the modifier names. If specified, it will only be reported if the specified modifier is used.element
...指定元素名称或模式。如果指定,则仅在指定元素上使用时才会报告。¥
element
... Specify the element name or pattern. If specified, it will only be reported if used on the specified element.message
...指定可选的自定义消息。¥
message
... Specify an optional custom message.
{ "argument": "foo", "modifiers": ["prop"] }
{ "argument": "foo", "element": "MyButton" }
👫相关规则
¥👫 Related Rules
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v7.0.0 中引入
¥This rule was introduced in eslint-plugin-vue v7.0.0
🔍代码实现
¥🔍 Implementation