| 1234567891011121314151617181920212223242526 |
- <template>
- <div>
- <h2>home</h2>
- <button @click="changeShow">切换</button>
- <!-- include exclude
- :include="['Part1']"
- -->
- <KeepAlive>
- <Part1 v-if="isShow"></Part1>
- <Part2 v-else></Part2>
- </KeepAlive>
- </div>
- </template>
- <script lang="ts" setup>
- import Part1 from "@/components/Part1.vue";
- import Part2 from "@/components/Part2.vue";
- import { ref, reactive } from "vue";
- let isShow = ref(true);
- function changeShow() {
- isShow.value = !isShow.value;
- }
- </script>
- <style lang="scss" scoped>
- </style>
|