- 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.
- 數(shù)據(jù)科學(xué)實(shí)戰(zhàn)手冊(R+Python)
- scikit-learn Cookbook
- Learning Data Mining with Python
- TypeScript實(shí)戰(zhàn)指南
- C語言從入門到精通
- Java程序員面試筆試寶典(第2版)
- 快速入門與進(jìn)階:Creo 4·0全實(shí)例精講
- 零基礎(chǔ)輕松學(xué)C++:青少年趣味編程(全彩版)
- Python大規(guī)模機(jī)器學(xué)習(xí)
- 高性能MVVM框架的設(shè)計(jì)與實(shí)現(xiàn):San
- Learning Apache Thrift
- Building Scalable Apps with Redis and Node.js
- Visual C++ 開發(fā)從入門到精通
- Learning Java Lambdas
- Python算法交易實(shí)戰(zhàn)