- 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.
- Learning Real-time Processing with Spark Streaming
- 軟件界面交互設計基礎
- Python Game Programming By Example
- C++程序設計基礎教程
- Hands-On Microservices with Kotlin
- Modular Programming in Java 9
- PHP 7+MySQL 8動態網站開發從入門到精通(視頻教學版)
- C++新經典
- 測試架構師修煉之道:從測試工程師到測試架構師
- WordPress Search Engine Optimization(Second Edition)
- 零基礎學Java第2版
- 金融商業數據分析:基于Python和SAS
- 編程的原則:改善代碼質量的101個方法
- C語言王者歸來
- 計算機常用算法與程序設計教程(第2版)