Skip to content

Router enters home "/" first #3475

@qxygene

Description

@qxygene

Version

3.5.1

Reproduction link

https://jsfiddle.net/chrisvfritz/50wL7mdz/

Steps to reproduce

Router enters home "/" first then another route at history mode on browser refresh or direct enter.

When hit http://localhost:8080/page, it goes to http://localhost:8080/ and after http://localhost:8080/page

How to prevent this?

const routes = [
{
path: '/home',
name: 'Home',
component: () => import('../views/Home.vue'),
},
{
path: '/page',
name: 'page',
component: () => import('../views/Page.vue'),
}
]

const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes,
});

What is expected?

Router enters home "/" first then another route at history mode on browser refresh or direct enter.

When hit http://localhost:8080/page, it goes to http://localhost:8080/ and after http://localhost:8080/page

How to prevent this?

const routes = [
{
path: '/home',
name: 'Home',
component: () => import('../views/Home.vue'),
},
{
path: '/page',
name: 'page',
component: () => import('../views/Page.vue'),
}
]

const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes,
});

What is actually happening?

Router enters home "/" first then another route at history mode on browser refresh or direct enter.

When hit http://localhost:8080/page, it goes to http://localhost:8080/ and after http://localhost:8080/page

How to prevent this?

const routes = [
{
path: '/home',
name: 'Home',
component: () => import('../views/Home.vue'),
},
{
path: '/page',
name: 'page',
component: () => import('../views/Page.vue'),
}
]

const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes,
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions