Vue · Template

VUE0029Do not read v-for variables in v-if on the same element

Flags `v-if` conditions that read the `v-for` variable on the same element.

Why it happens

In Vue 3, v-if has higher precedence than v-for on the same element, so the condition runs before the loop and the loop variable is undefined: the render throws or hides the whole list instead of filtering it.

Fix

Loop over a filtered computed, or move v-for to a wrapping <template> and keep v-if on the inner element.

Example

Filter before looping

Before

<template>
  <li v-for="item in items" :key="item.id" v-if="item.active">{{ item.name }}</li>
</template>

After

<template>
  <template v-for="item in items" :key="item.id">
    <li v-if="item.active">{{ item.name }}</li>
  </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-v-if-with-v-for
Copyright © 2026