The following answers are quoted from GPT-3 model, please use them wisely:
示例
<template>
<div>
<div class="box-1" v-show="showBox1">Box 1div>
<div class="box-2" v-if="showBox2">Box 2div>
<input type="button" @click="handleClick" value="切换"/>
div>
template>
<script>
export default {
data() {
return {
showBox1: true,
showBox2: false
}
},
methods: {
handleClick(){
this.showBox1 = !this.showBox1;
this.showBox2 = !this.showBox2;
}
}
}
script>
<style>
.box-1{
width: 200px;
height: 200px;
background: #ccc;
}
.box-2{
width: 200px;
height: 200px;
background: #333;
}
style>
Please accept my answer if it answers your question