1
votes

For some reason my vue-router breaks links. For example, when I setup <router-link to="/user/bar">... I've got this in url:

/http:/siteexample.com/user/bar

this should be http:// instead /http:/

So, why urls are not formatted properly?

My routes example:

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:

Actually its ok, but problem was - my urls becomes like that: http://siteexample.com/http:/siteexample.com/user/bar

I've replaced this line in vue-router.js

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

to

pushState(cleanPath(route.fullPath))

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

And now all works fine, but I'm not sure - is this is a bug or not.

1
Do you getting any exception in console ? And try to get rid of history mode, it require some adjustments on server side.Belmin Bedak
{path : '/user', component: Network}, don't put slash at the end of pathMarek Urbanowicz

1 Answers

0
votes

The problem was - <base href="/"> tag in head. Remove it and all will be fine.