v-else Conditional Branch (Else)

Last updated: 2026-10-22

v-else Conditional Branch (Else)

v-else provides the 'otherwise' branch for v-if: it renders when v-if is falsy and takes no expression.

GroupDirectives
KindDirective
ScopeTemplate
Vue Version3.0+
SSR SupportYes

📝 Syntax

<p v-if="loggedIn">Welcome back</p>
<p v-else>Please log in</p>

⚙️ Arguments

expressionNo expression

Returns:Directive, no return value

▶ Example

Edit the code below and see the live result:

Output:

The page shows 'Pass'; change score to 50 to see 'Fail'.

💡 Key Points

⚠️ Warning v-else must directly follow the v-if / v-else-if element — no elements or comments in between.
💡 Tip Chain multiple branches with v-else-if and close with a single v-else.
ℹ️ Note The v-else element must be the immediate sibling of the v-if element.
More case studies coming soon.

📚 Related Tutorials

❓ FAQ

Q Must v-else directly follow v-if?
A Yes — any element or comment in between breaks the pairing.
Q Can there be more than one v-else?
A No — one chain has a single trailing v-else; use v-else-if for middle conditions.
Q Does v-else take an expression?
A No — it renders whenever the preceding branch is falsy.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏