Appearance
vue/no-v-text-v-html-on-component
禁止组件上的 v-text / v-html
- ⚙️ 此规则包含在
"plugin:vue/vue2-essential"
、*.configs["flat/vue2-essential"]
、"plugin:vue/essential"
、*.configs["flat/essential"]
、"plugin:vue/vue2-strongly-recommended"
、*.configs["flat/vue2-strongly-recommended"]
、"plugin:vue/strongly-recommended"
、*.configs["flat/strongly-recommended"]
、"plugin:vue/vue2-recommended"
、*.configs["flat/vue2-recommended"]
、"plugin:vue/recommended"
和*.configs["flat/recommended"]
中。
📖 规则详情
此规则禁止在组件上使用 v-text / v-html。
¥This rule disallows the use of v-text / v-html on component.
如果你在组件上使用 v-text / v-html,它将覆盖组件的内容并可能破坏组件。
¥If you use v-text / v-html on a component, it will overwrite the component's content and may break the component.
🔧选项
¥🔧 Options
json
{
"vue/no-v-text-v-html-on-component": ["error", {
"allow": ["router-link", "nuxt-link"],
"ignoreElementNamespaces": false
}]
}
allow
(string[]
) ...指定不应应用规则的自定义组件列表。¥
allow
(string[]
) ... Specify a list of custom components for which the rule should not apply.ignoreElementNamespaces
(boolean
) ...如果是true
,则始终将 SVG 和 MathML 标签名称视为 HTML 元素,即使它们未在 SVG/MathML 根元素中使用。默认值为false
。¥
ignoreElementNamespaces
(boolean
) ... Iftrue
, always treat SVG and MathML tag names as HTML elements, even if they are not used inside a SVG/MathML root element. Default isfalse
.
{ "allow": ["router-link", "nuxt-link"] }
{ "ignoreElementNamespaces": true }
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v8.4.0
¥This rule was introduced in eslint-plugin-vue v8.4.0
🔍代码实现
¥🔍 Implementation