鍍金池/ 問答/網(wǎng)絡安全  HTML/ 關于 router-view 三級路由沒有切換出相應組件。

關于 router-view 三級路由沒有切換出相應組件。

clipboard.png
首先先看一下原圖,點擊左側一級導航路由出二級導航,點擊二級導航出內(nèi)容

clipboard.png
<template>
<div id="app" class="clearfix">

<TopNavigationBar></TopNavigationBar> <!--原圖紅色區(qū)域-->
<div class="main">
  <SideNavigation></SideNavigation> <!--原圖藍色區(qū)域-->

  <div class="main-right">
    <router-view></router-view>   <!--原圖綠色區(qū)域-->
    <router-view name="table"></router-view>  <!--原圖黑色區(qū)域-->
  </div>
</div>

</div>
</template>
因為添加代碼有點問題,所以這個是整個布局的代碼截圖,因為同時有兩個兩個視圖,第二個試圖加了name屬性

clipboard.png
routes: [{

        path: '/',
        name: 'login',
        component: ()=>import('@/views/login/login')
    },
    {
        path: '/layout',
        name: 'layout',
        // redirect: 'layout/TwoLevelHeadlines',
        component: ()=>import('@/views/layout/AppMain'),
        children: [{
            name: 'TwoLevelHeadlines',
            path: 'TwoLevelHeadlines',
            component: ()=>import('@/views/layout/TwoLevelHeadlines'),
            children: [{
                name: 'department',
                path: 'department',
                component: {
                    table: ()=>import('@/views/supplier/basicSettings/department')},
            }]
        }]
    }
]

這張是router的代碼。先登陸再進入到layout,然后點擊側邊的一級標題路由出二級標題,最后點擊二級標題的時候路由出最后的內(nèi)容,在三級路由中的component屬性也給了router-view中的name值,找了好久也沒找到問題

clipboard.png
這邊的url已經(jīng)添加了department,但是組件沒有出來,想問一下大佬是什么原因,是布局的問題還是router中的代碼有問題

clipboard.png

<template>
<div id="app">

<router-view></router-view>

</div>
</template>
這個是App.vue中的代碼,不知道跟這里有沒有關系

回答
編輯回答
半心人

AppMain?組件內(nèi)部 需要有router-view
PS: id=app重復了,不規(guī)范

2017年3月19日 18:44