--- title: v-else Must Immediately Follow v-if or v-else-if impact: MEDIUM impactDescription: Misplaced v-else causes a compile-time error in SFCs, or renders unconditionally with runtime template compilation type: capability tags: [vue3, conditional-rendering, v-if, v-else, v-else-if] --- # v-else Must Immediately Follow v-if or v-else-if **Impact: MEDIUM** - A `v-else` or `v-else-if` element must immediately follow a `v-if` or `v-else-if` element in the DOM. If there's any element in between: - **SFC compilation (Vite/vue-loader):** Vue throws a **compile-time SyntaxError** - the code won't build at all - **Runtime template compilation:** The element renders unconditionally (always visible), losing its conditional behavior In most modern Vue projects using Single File Components, this is caught at build time. ## Task Checklist - [ ] Place v-else immediately after the v-if element (no elements in between) - [ ] Place v-else-if immediately after v-if or another v-else-if - [ ] Use `