Vue路由器2断开链接
问题描述:
由于某种原因,我的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
现在一切工作正常,但我不知道 - 是这是一个错误或没有。
答
问题是 - <base href="/">
标签在头部。 删除它,一切都会好起来的。
你是否在控制台中发现任何异常?并尝试摆脱历史模式,它需要在服务器端进行一些调整。 –
'{path:'/ user',component:Network},'不要在路径末尾放置斜杠 –