Skip to content

vue/no-restricted-html-elements

禁止特定元素

¥disallow specific elements

📖 规则详情

此规则允许你指定不想在应用中使用的 HTML、SVG 和 MathML 元素。

¥This rule allows you to specify HTML, SVG, and MathML elements that you don't want to use in your application.

Now loading...

🔧选项

¥🔧 Options

此规则接受一个字符串列表,其中每个字符串都是要限制的元素名称:

¥This rule takes a list of strings, where each string is an element name to be restricted:

json
{
  "vue/no-restricted-html-elements": ["error", "a", "marquee"]
}
Now loading...

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

¥Alternatively, the rule also accepts objects.

json
{
  "vue/no-restricted-html-elements": [
    "error",
    {
      "element": ["a", "RouterLink"],
      "message": "Prefer the use of <NuxtLink> component"
    },
    {
      "element": "marquee",
      "message": "Do not use deprecated HTML tags"
    }
  ]
}

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

¥The following properties can be specified for the object.

  • element ...指定元素名称或元素名称数组。

    ¥element ... Specify the element name or an array of element names.

  • message ...指定可选的自定义消息。

    ¥message ... Specify an optional custom message.

{ "element": "marquee" }, { "element": "a" }

Now loading...

🚀版本

¥🚀 Version

此规则在 eslint-plugin-vue v8.6.0 中引入

¥This rule was introduced in eslint-plugin-vue v8.6.0

🔍代码实现

¥🔍 Implementation

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