Skip to content

vue/no-template-shadow

禁止变量声明覆盖外部作用域中声明的变量

  • ⚙️ 此规则包含在 "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-for 指令或范围属性的变量定义遮蔽了父范围中的变量,则 no-template-shadow 应该报告这些变量定义。

¥no-template-shadow should report variable definitions of v-for directives or scope attributes if they shadow the variables in parent scopes.

📖 规则详情

此规则旨在消除 v-for 指令或范围属性的阴影变量声明。

¥This rule aims to eliminate shadowed variable declarations of v-for directives or scope attributes.

Now loading...

🔧选项

¥🔧 Options

此规则采用一个可选对象选项,其属性为 "allow"

¥This rule takes one optional object option, with the property "allow".

json
{
  "vue/no-template-shadow": ["error", { "allow": [] }]
}
  • "allow"[string])允许阴影的标识符名称数组。

    ¥"allow" ([string]) Array of identifier names for which shadowing is allowed.

{ "allow": ["i"] } 选项的正确代码示例:

¥Examples of correct code for the { "allow": ["i"] } option:

Now loading...

🚀版本

¥🚀 Version

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

¥This rule was introduced in eslint-plugin-vue v5.0.0

🔍代码实现

¥🔍 Implementation

eslint-plugin-vue v10.0 中文网 - 粤ICP备13048890号