[Vue] Conditionally Render DOM Elements in Vue.js (v-if v-else v-show)
Posted Answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Vue] Conditionally Render DOM Elements in Vue.js (v-if v-else v-show)相关的知识,希望对你有一定的参考价值。
You can use v-if
and v-else
to display content based on assertions on your data. Similarly, v-show
can be used to render the content, but hide it with css. v-if
can also be used on an invisible wrapper <template>
element.
v-if v-else:
It is good that when you use ‘v-if‘ you wrap the html into ‘<template>‘:
<template v-if="counter > 5"> <div>Show if the counter is greater than five</div> </template>
‘v-else‘: will be rendered if the closeset ‘v-if‘ doesn‘t render:
<template v-if="counter > 5"> <div>Show if the counter is greater than five</div> </template> <div v-else>Show the counter is smaller than five</div>
v-show:
<button @click="dec" v-show="counter > 0">-</button> <button @click="inc" v-show="counter < 5">+</button>
以上是关于[Vue] Conditionally Render DOM Elements in Vue.js (v-if v-else v-show)的主要内容,如果未能解决你的问题,请参考以下文章
[Javascript] Conditionally spread entries to a JavaScript object
pandas基于条件判断更新dataframe中特定数据列数值内容的值(Conditionally updating values in specific pandas Dataframe )
pandas基于条件判断更新dataframe中特定数据列数值内容的值(Conditionally updating values in specific pandas Dataframe )
pandas基于applymap函数和lambda条件判断并基于规则函数更新dataframe中所有数据列数值内容的值(Conditionally updating values in pandas