Skip to content

vue-router current path invalid for a short time when loading async component #2703

@719media

Description

@719media

Version

3.0.3

Reproduction link

https://codesandbox.io/s/y32jkmjr7v

Steps to reproduce

Using vue and vue-router, create a route that requires a component (componentAsync) that is async loaded from the main component (componentApp).

Do something that uses router.push or router.go inside of mounted() of the componentApp without a path or name.
For example, router.push({query: { test: 'foo' }})

The redirected route will just use path: '/' instead of the actual path you used to initially hit the page.

For example, if you hit domain.com/about, you will wind up at domain.com/?test=foo, instead of domain.com/about?test=foo

What is expected?

vue-router would use the current window location

What is actually happening?

vue-router is using /


This is because the async component makes the confirmTransaction callback take longer than the mounted() call to router.push, so the route inside router is still the one with the wrong path.

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