代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<!-- v-if:当条件为false时,包含v-if指令的元素,根本不会存在dom中-->
<h2 v-if="isShow" id="a">{{message}}</h2>
<!-- v-show:当条件为false,v-show只是元素添加一个行内样式display:none,仍存在dom中-->
<h2 v-show="isShow" id="b">{{message}}</h2>
<!-- 应用情景:-->
<!-- 当只有一次切换时,使用v-if(实际开发使用较多)-->
<!-- 当在显示与隐藏之间频繁切换时,使用v-show-->
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
message: 'simplelu',
isShow: true
}
})
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。