<!-- if判断 -->
<div id="app2">
<p v-if="seen"> <!-- 给p标签绑定指令 -->
显示内容
</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var app2 = new Vue({
el: "#app2",
data: {
seen: true
}
});
</script>
Enter the console app2.seen
will get value app2 seen in the data, but can also be assigned to false
, so will the p
label be removed from the document, and then if it is assigned true
, it will re-display, and the document will appear p
in the label