Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v-if and v-else on same element has inconsistent (or undocumented) behaviour #13238

Closed
Bl00D4NGEL opened this issue Feb 28, 2025 · 1 comment
Closed

Comments

@Bl00D4NGEL
Copy link

Problem

When using v-if and v-else on the same element it has weird behaviour.

I am currently running Vue version 3.5.13

Example Code

Example:

<div v-if="false">False</div>
<div v-else v-if="true">True</div>
<div v-else>True 2</div>

will show True 2 instead of True. However

<div v-if="false">False</div>
<div v-else v-if="true">True</div>

will show True.

Using a v-else-if like this:

<div v-if="false">False</div>
<div v-else-if="true">True</div>
<div v-else>True 2</div>

will show True as expected.

Expected

I would either expect there to be an error of "incorrect use" of v-if and v-else on the same element or similar behaviour to a v-else-if instead of.. what's currently happening. I might have missed this in the documentation but I could not find any mention of this behaviour anywhere.

@Bl00D4NGEL
Copy link
Author

Just noticed this is the repo for Vue 2. However my issue happens in Vue 3 (it might happen in Vue 2 but I don't think it'd matter).

See: vuejs/core#12997

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@Bl00D4NGEL and others