- Vue.js 2.x by Example
- Mike Street
- 176字
- 2021-07-02 20:00:26
v-else
v-else allows you to render an alternative element based on the opposite of the v-if statement. If that results in true, the first element will be displayed; otherwise, the element containing v-else will.
The element with v-else needs to directly follow the one containing v-if; otherwise, your application will throw an error.
v-else has no value and is placed within the element tag.
<p id="app">
<p v-if="isVisible">
Now you see me
</p>
<p v-else>
Now you don't
</p>
</p>
Adding the preceding HTML to your app space will only show one of the <p> elements – toggling the value in your console as we did earlier will reveal the other container. You can also use v-else-if should you wish to chain your conditions. An example of v-else-if is as follows:
<p id="app">
<p v-if="isVisible">
Now you see me
</p>
<p v-else-if="otherVisible">
You might see me
</p>
<p v-else>
Now you don't
</p>
</p>
You might see me will be displayed if the isVisible variable equates to false, but the otherVisible variable equates to true.
v-else should be used sparingly as can be ambiguous and might lead to false positive situation.
- WildFly:New Features
- Java面向對象軟件開發
- VSTO開發入門教程
- Functional Programming in JavaScript
- Java Web程序設計
- Access 2016數據庫管
- Learning ELK Stack
- 從0到1:Python數據分析
- Protocol-Oriented Programming with Swift
- Android群英傳
- C++ Application Development with Code:Blocks
- LabVIEW數據采集
- Instant GLEW
- Deep Learning for Natural Language Processing
- MySQL核心技術與最佳實踐