Vue使用v-if v-show v-for指令
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>v-if v-show v-for指令</title>
</head>
<script src="./vue.js"></script>
<body>
<div id="root">
<div v-if="show">hello world</div>
<button @click="handleClick">toggle</button>
<ul>
<li v-for="(item, index) of list" :key="index">{{item}}</li>
</ul>
</div>
<script>
new Vue({
el: '#root',
data: {
show: true,
list: [1,2,3]
},
methods: {
handleClick: function () {
this.show = !this.show;
}
}
})
</script>
</body>
</html>
```![在这里插入图片描述](https://img-blog.csdnimg.cn/20190810174623153.gif)