-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path条件渲染.html
44 lines (35 loc) · 1.3 KB
/
条件渲染.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<p>v-if 是通过控制标签是否存在来控制内容是否显示 v-else 可以直接写 if判断为false执行else 省略的写法需要两者贴在一起</p>
<p>v-else-if 中间者 if为false 则进行判断else-if 也为false时在执行else</p>
<p>v-show 是通过行内样式diaplay控制的 频繁时使用</p>
<div id="root"></div>
<script>
const app = Vue.createApp({
data() {
return {
show: true,
conditionOne: false,
conditionTwo: true
}
},
template:
`
<div v-if = "show">Hello World1</div>
<div v-if = "conditionOne">if</div>
<div v-else-if = "conditionTwo">elseif</div>
<div v-else>else</div>
<div v-show = "show"> Hello World2</div>`
});
const vm = app.mount('#root')
</script>
</body>
</html>