v-else-if
v-else-if 即 v-if 的 else-if 块,可以链式的使用多次:
v-else 指令
判断 type 变量的值:
<div id="app">
<div v-if="type === 'A'">
A
</div>
<div v-else-if="type === 'B'">
B
</div>
<div v-else-if="type === 'C'">
C
</div>
<div v-else>
Not A/B/C
</div>
</div>
<script>
const app = {
data() {
return {
type: "C"
}
}
}
Vue.createApp(app).mount('#app')
</script>
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h64984.shtml