<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>条件语句</title>
<script src="js/vue.js"></script>
</head>
<body>
<div id="app">
<!-- v-if -->
<p v-if="seen">现在你看到我了</p>
<template v-if="ok">
<h1>菜鸟教程</h1>
<p>学的不仅是技术</p>
</template>
<!-- v-else -->
<div v-if="Math.random() > 0.5"></div>
sorry
<div v-else>yes</div>
<!-- v-else-if -->
<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="type === 'A'">
not a\b\c
</div>
<!-- v-show -->
<h1 v-show="ok">htllo</h1>
</div>
</body>
<script>
new Vue({
el: '#app',
data: {
seen: true,
ok: true,
type:'C'
}
})
</script>
</html>
12-21
3504
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)