2017-02-20 108 views
0

我在vuejs和由於某種原因,它不顯示內容時切換到另一個路線。我有以下代碼: 在App.vue - >路由器不顯示內容VueJS

<template> 
<div> 
<router-view> </router-view> 
</div> 
</template> 

在我routes.js - >

import Support from './components/support/Support.vue'; 
import Detailed from './components/support/details/Detailed.vue'; 

export const routes =[ 

{path: '/support', component: Support, children: [ 
    {path: 'detailed', component: Detailed, name: 'detailed'} 
]}, 
]; 
我Support.vue

我有一個組件 - >

<div class="row"> 

<component :is = "selectedComponent"> </component> 

     </div> 

並且選中該組件時會顯示某些內容。這裏面的內容我有 - >

 <div class="most-asked"> 
    <ul> 
     <router-link :to ="{name: 'detailed'}" tag = 'li'> Test </router-link> 

    </ul> 

當我按它的URL改變了我的瀏覽器=>「/支持/詳細」,但它不我重定向到該頁面。 關於爲什麼會發生以及如何解決它的任何想法?

PS如果我讓航線routes.js單獨像 - > /詳細和/支,然後將其重定向我完全沒有問題,但一旦我做支撐一個孩子,它不去了,

PSS和由於某種原因,它告訴我,有時我的瀏覽器,它無法加載文件,如 (Failed to load resource: http://localhost:8080/support/src/vendors/css/grid.css Failed to the server responded with a status of 404 (Not Found)

http://localhost:8080/support/src/vendors/css/ionicons.min.css Failed to load resource: the server responded with a status of 404 (Not Found)

我假設,如果我包括引導和等,其也不會找到它的路線(爲什麼?),但是如果把所有這些路線分開放置,沒有任何c孩子們工作得很好。

+0

更改路徑爲'/詳細'在子路線 –

+0

我以前試過。在瀏覽器url中,它會更改爲/詳細信息,但會保留在/ support的同一頁面上 – Stan

回答

1

據我瞭解它不顯示它的原因,因爲它需要另一個<router-view> </router-view>除了根目錄之外。因此,轉發問題是,您可以創建什麼樣的邏輯來切換網頁?