Vue · VUE0029

Do 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.
VUE0029vite-doctor/vuetemplateerrorNo fix

Run this rule

pnpm vite-doctor . --framework vue --rules vue/template/no-v-if-with-v-for

Why it matters

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.

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>
Copyright © 2026