使用v-show的时候,被隐藏的属性还在页面上,只不过css中的属性被设置为了 display:none,当页面需要频繁切换的时候可以使用v-show
<template>
<div class="hello">
<div>
<label v-show="sta">张三丰</label>
<label v-show="!sta">张翠山</label>
</div>
<button @click="changeSta">换人</button>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data () {
return {
sta: false
}
},
methods: {
changeSta () {
this.sta = !this.sta
}
},
computed: {
},
async created () {
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>