【发布时间】:2016-12-04 22:19:26
【问题描述】:
由于某种原因,我的 vue-router 断开了链接。
例如,当我设置 <router-link to="/user/bar">... 时,我在 url 中有这个:
/http:/siteexample.com/user/bar
这应该是http:// 而不是/http:/
那么,为什么网址格式不正确?
我的路线示例:
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
现在一切正常,但我不确定 - 这是否是一个错误。
【问题讨论】:
-
控制台有异常吗?并尝试摆脱历史模式,它需要在服务器端进行一些调整。
-
{path : '/user', component: Network},不要在路径末尾添加斜杠
标签: vue.js vue-router