v-else-if Conditional Branch (Else If)

Last updated: 2026-10-22

v-else-if Conditional Branch (Else If)

v-else-if chains multiple conditional branches, evaluating each until one is truthy.

GroupDirectives
KindDirective
ScopeTemplate
Vue Version3.0+
SSR SupportYes

📝 Syntax

<p v-if="t >= 90">Excellent</p>
<p v-else-if="t >= 60">Pass</p>
<p v-else>Fail</p>

⚙️ Arguments

expressionA boolean expression, evaluated in order (short-circuit)

Returns:Directive, no return value

▶ Example

Edit the code below and see the live result:

Output:

Enter 75 for 'Pass', 95 for 'Excellent', 40 for 'Fail'.

💡 Key Points

ℹ️ Note Conditions evaluate top-down and stop at the first match — order from strictest to loosest.
⚠️ Warning Each v-else-if must directly follow the previous branch — the chain cannot be interrupted.
💡 Tip With more than three branches, return a status from a computed property to keep the template clean.
More case studies coming soon.

📚 Related Tutorials

❓ FAQ

Q Does the order of v-else-if matter?
A Yes. Conditions short-circuit top-down, so put the strictest first.
Q Do many branches make the template messy?
A With more than three, derive a status via computed and compare that single value.
Q Can v-else-if mix with v-show?
A No — the chain only pairs v-if, v-else-if and v-else.
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%

🙏 帮我们做得更好

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

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