VUE問題記錄-子組件router-view跳轉

要實現子組件之間的跳轉,必須有一個公共的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: '接口名稱' },
    }]
},

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章