官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 武夷山市| 镇坪县| 盱眙县| 铁岭县| 从化市| 黄浦区| 襄城县| 宁蒗| 汪清县| 金华市| 建始县| 谷城县| 太仓市| 九寨沟县| 嘉祥县| 博野县| 同心县| 电白县| 东光县| 连山| 阿图什市| 腾冲县| 栖霞市| 乌拉特前旗| 兰西县| 黄石市| 奎屯市| 乾安县| 双峰县| 瑞丽市| 昭苏县| 横山县| 江城| 江孜县| 沽源县| 蒙自县| 雷州市| 申扎县| 科技| 宝应县| 郑州市|