Vue · Attributes
Finds a component usage that passes attributes or listeners, such as `class`, `id` or `@click`, to a component whose template has more than one root node, when the component declares none of them as props, `defineModel()` props or emits, keeps `inheritAttrs` on, and never reads `$attrs`, `useAttrs()` or `getCurrentInstance()`. A `v-if`/`v-else-if`/`v-else` chain counts as one root and comments are not roots, as in Vue's compiler. Doctor reports at the usage, only for usages it resolved to the component, and skips spreads such as `v-bind="obj"`, `key` and `ref`, and `update:*` model listeners. When Nuxt generates a lazy hydration wrapper, Doctor skips the strategy prop and `hydrated` listeners that the wrapper consumes. Components whose props it cannot read, such as `defineProps<ImportedProps>()` or an Options API `props` option, are skipped; listeners are skipped when the emits are unreadable. Strict Preset only.
vite-doctor/vueattrswarnNo fix
Why it happens
Vue normally forwards undeclared attributes and listeners to a single root element or component. With several roots, Vue does not automatically attach them and warns in development. A component can still emit an undeclared event and invoke the caller's listener; missing DOM inheritance does not mean the listener is unused.
Fix
Bind $attrs on the intended root with v-bind="$attrs" or wrap the template in one root element. Declare inputs the component consumes as props. If the component emits the event, declare it in emits or defineEmits() and keep the caller’s listener.
Example
Bind $attrs on the root that should receive them
Before
<!-- PageLayout.vue -->
<template>
<header>Title</header>
<main><slot /></main>
</template>
<!-- Page.vue -->
<template>
<PageLayout class="page" />
</template>
After
<!-- PageLayout.vue -->
<template>
<header>Title</header>
<main v-bind="$attrs"><slot /></main>
</template>
<!-- Page.vue -->
<template>
<PageLayout class="page" />
</template>
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --framework vue --extends auto,vue/strict --rules vue/attrs/no-multi-root-fallthrough