Vue · Template

VUE0044Do not put attributes on a structural <template>

Reports attributes and directives Vue does not apply on a <template> with v-if, v-else-if, v-else, v-for or v-slot.

Why it happens

A structural <template> does not render an element. Attributes such as id, class, slot, listeners and refs never reach a rendered element, and key and caching directives only work on certain structural templates.

Fix

Apply the attribute or directive to an intended rendered target that supports it. Preserve branch selection when adding visibility, and keep working list keys on a non-slot <template v-for>.

Example

Put the id on a rendered element

Before

<template>
  <template v-if="open" id="panel">
    <section>{{ details }}</section>
  </template>
</template>

After

<template>
  <template v-if="open">
    <section id="panel">{{ details }}</section>
  </template>
</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 --rules vue/template/no-useless-template-attributes
Copyright © 2026