要實現子組件之間的跳轉,必須有一個公共的router-view父組件
父組件:router-view轉換的場所,展示子組件外的共有內容,不是具體頁面,所以不要加name屬性
父組件(寫成通用的公共組件):
<template>
<div>
<router-view :key="key" />
</div>
</template>
<script>
export default {
name: 'AppRouter',
computed: {
key() {
return this.$route.path
}
}
}
</script>
router.js
{
path: '/JieKouLB',
component: AppRouter,
meta: { title: '接口列表' },
// 父組件只是router-view轉換的場所,展示子組件外的共有內容,不是具體頁面,所以不要加name屬性
children: [{
path: '/JieKouLB',
component: JieKouLB,
name: 'JieKouLB',
meta: { title: '' },
},
{
path: 'JieKouMC',
component: JieKouMC,
name: 'JieKouMC',
meta: { title: '接口名稱' },
}]
},