本文主要是【Vue】——Vue实现条件渲染的文章,如果有什么需要改进的地方还请大佬指出⛺️
作者简介:大家好,我是听风与他
☁️博客首页:CSDN主页听风与他
每日一句:狠狠沉淀,顶峰相见
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
<script src="https://unpkg.com/vue@3/dist/vue.global.js">script>
head>
<body>
<div id="Application">
<h1 v-if="show">标题h1>
<p v-else>如果不显示标题就显示段落p>
<p>你好呀p>
div>
<script>
const App = {
data(){
return{
show:true, //控制元素是否渲染
}
}
}
Vue.createApp(App).mount("#Application")
script>
body>
html>
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
<script src="https://unpkg.com/vue@3/dist/vue.global.js">script>
head>
<body>
<div id="Application">
<h1 v-if="show">标题h1>
<p>你好呀p>
<p v-else>如果不显示标题就显示段落p>
div>
<script>
const App = {
data(){
return{
show:true, //控制元素是否渲染
}
}
}
Vue.createApp(App).mount("#Application")
script>
body>
html>