Appearance
vue/no-undef-components
禁止在
<template>
中使用未定义的组件¥disallow use of undefined components in
<template>
此规则报告在 <template>
中使用但未在 <script setup>
或 Options API 的 components
部分中定义的组件。
¥This rule reports components that are used in the <template>
, but that are not defined in the <script setup>
or the Options API's components
section.
未定义的组件将从全局注册的组件中解析。但是,如果你不使用全局组件,则可以使用此规则来防止运行时错误。
¥Undefined components will be resolved from globally registered components. However, if you are not using global components, you can use this rule to prevent run-time errors.
注意
此规则无法检查全局注册的组件和在 mixin 中注册的组件,除非你将它们添加为忽略模式的一部分。
¥This rule cannot check globally registered components and components registered in mixins unless you add them as part of the ignored patterns.
🔧 选项
json
{
"vue/no-undef-components": ["error", {
"ignorePatterns": []
}]
}
ignorePatterns
如果组件名称与一个或多个模式匹配,则抑制所有错误。¥
ignorePatterns
Suppresses all errors if component name matches one or more patterns.
ignorePatterns: ['custom(\\-\\w+)+']
👫相关规则
¥👫 Related Rules
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v8.4.0
¥This rule was introduced in eslint-plugin-vue v8.4.0
🔍代码实现
¥🔍 Implementation