perf: router

This commit is contained in:
xiaoxian521
2022-01-04 17:28:36 +08:00
parent 07794d000c
commit 079a455181
6 changed files with 19 additions and 16 deletions

57
src/views/tabs/index.vue Normal file
View File

@@ -0,0 +1,57 @@
<script setup lang="ts">
import { ref } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
const router = useRouter();
const route = useRoute();
const activeName = ref("tag");
function toDetail(index: number) {
useMultiTagsStoreHook().handleTags("push", {
path: `/tabs/detail`,
parentPath: route.matched[0].path,
name: "tabDetail",
query: { id: String(index) },
meta: {
title: { zh: `No.${index} - 详情信息`, en: `No.${index} - DetailInfo` },
showLink: false,
i18n: false,
dynamicLevel: 3
}
});
router.push({ name: "tabDetail", query: { id: String(index) } });
}
</script>
<template>
<el-collapse v-model="activeName" class="tabs-container">
<el-collapse-item
title="标签页复用超出限制自动关闭(使用场景: 动态路由)"
name="tag"
>
<el-button v-for="index in 6" :key="index" @click="toDetail(index)">
打开{{ index }}详情页
</el-button>
</el-collapse-item>
</el-collapse>
</template>
<style lang="scss" scoped>
.tabs-container {
padding: 10px;
background: #fff;
::v-deep(.el-collapse-item__header) {
line-height: 20px;
}
::v-deep(.el-collapse-item__wrap) {
border-bottom: none;
}
button {
margin: 10px;
}
}
</style>