2016-12-04 106 views
0

由於某種原因,我的vue路由器斷開鏈接。 例如,當我安裝<router-link to="/user/bar">...我在URL得到這個:Vue路由器2斷開鏈接

/http:/siteexample.com/user/bar 

這應該是http://代替/http:/

那麼,爲什麼用URL格式不正確?

我的路線例如:

var routes = [ 
    {path  : '/user/', component: Network}, 
    {path  : '/user/foo', component: Foo}, 
    {path  : '/user/bar', component: Bar}, 
    {path  : '*', component: Notfound} 
]; 

var router = new VueRouter({ 
    mode: 'history', 
    routes: routes 
}); 


UPD:

其實它的好,但問題是 - 我的網址變成這樣:http://siteexample.com/http:/siteexample.com/user/bar

我已經更換了這條線在vue-router.js中

pushState(cleanPath(this$1.base + route.fullPath)) 

pushState(cleanPath(route.fullPath)) 

https://github.com/vuejs/vue-router/blob/dev/dist/vue-router.js#L1682-L1690

現在一切工作正常,但我不知道 - 是這是一個錯誤或沒有。

+0

你是否在控制檯中發現任何異常?並嘗試擺脫歷史模式,它需要在服務器端進行一些調整。 –

+1

'{path:'/ user',component:Network},'不要在路徑末尾放置斜槓 –

回答

0

問題是 - <base href="/">標籤在頭部。 刪除它,一切都會好起來的。