Appearance
vue/valid-v-model
强制有效的
v-model
指令
- ⚙️ 此规则包含在
"plugin:vue/essential"
、*.configs["flat/essential"]
、"plugin:vue/vue2-essential"
、*.configs["flat/vue2-essential"]
、"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"]
中。
此规则检查每个 v-model
指令是否有效。
¥This rule checks whether every v-model
directive is valid.
📖 规则详情
此规则在以下情况下报告 v-model
指令:
¥This rule reports v-model
directives in the following cases:
HTMLElement 上使用的指令有一个参数。例如
<input v-model:aaa="foo">
¥The directive used on HTMLElement has an argument. E.g.
<input v-model:aaa="foo">
HTMLElement 上使用的指令具有不受支持的修饰符。例如
<input v-model.bbb="foo">
¥The directive used on HTMLElement has modifiers which are not supported. E.g.
<input v-model.bbb="foo">
该指令没有该属性值。例如
<input v-model>
¥The directive does not have that attribute value. E.g.
<input v-model>
该指令没有作为 LHS 有效的属性值。例如
<input v-model="foo() + bar()">
,<input v-model="a?.b">
¥The directive does not have the attribute value which is valid as LHS. E.g.
<input v-model="foo() + bar()">
,<input v-model="a?.b">
该指令具有潜在的空对象属性访问权限。例如
<input v-model="(a?.b).c">
¥The directive has potential null object property access. E.g.
<input v-model="(a?.b).c">
该指令位于不受支持的元素上。例如
<div v-model="foo"></div>
¥The directive is on unsupported elements. E.g.
<div v-model="foo"></div>
该指令位于其类型为
file
的<input>
元素上。例如<input type="file" v-model="foo">
¥The directive is on
<input>
elements which their types arefile
. E.g.<input type="file" v-model="foo">
该指令的引用是迭代变量。例如
<div v-for="x in list"><input type="file" v-model="x"></div>
¥The directive's reference is iteration variables. E.g.
<div v-for="x in list"><input type="file" v-model="x"></div>
注意
此规则不检查指令中的语法错误,因为它由 vue/no-parsing-error 规则检查。
¥This rule does not check syntax errors in directives because it's checked by vue/no-parsing-error rule.
🔧选项
¥🔧 Options
无。
¥Nothing.
👫相关规则
¥👫 Related Rules
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v3.11.0 中引入
¥This rule was introduced in eslint-plugin-vue v3.11.0
🔍代码实现
¥🔍 Implementation