VueJs V-show,v-if and v-for
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue JS V-show, v-for,v-if</title>
<script src='./vue.js'></script>
</head>
<body>
<div id="root">
<!-- v-if delete the dom
v-show just set the display:none -->
<div v-if="show">hello plmhome</div>
<button @click="toggle">toggle to display</button>
<ul>
<li v-for="(item,index) in list" :key="index">{{item}}</li>
</ul>
</div>
<script>
new Vue({
el: "#root",
data:{
show: true,
list:['plm','home','I','love','you']
},
methods:{
toggle:function(){
this.show = !this.show;
}
}
})
</script>
</body>
</html>
页:
[1]