1

In my component I have the following vue-router routes one with a dynamic event of '/event/:id'

    routes: [
        {
            path: '/',
            name: 'Dashboard',
            component: Dashboard
        },
        {
            path: '/events',
            name: 'Events',
            component: Events,
            beforeEnter: requireAuth
        },
        {
            path: '/event/:id',
            name: 'Event details',
            component: EventDetails,
            alias: 'test'
        }
    ]

When I visit an event ID url like this one: http://localhost:8080/event/59f4906d8835582773ef769a everything is fine and the event detail page is loaded. However if I try to navigate away from this component to for example the /events page the events component does not load and I stay on the same page.

The links I use to navigate away from the page are formatted with the <router-link> like this:

<router-link to="events">Events</router-link>
1
  • What does the url look like after you try to navigate? Commented Oct 29, 2017 at 8:06

2 Answers 2

2

You should add / in route path.

Change this <router-link to="events">Events</router-link> to <router-link to="/events">Events</router-link>

If you still have problem, check out this example: http://jsfiddle.net/657f3twk/

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! How did I look over this, it's so obvious :-D
0

Try exact links

<router-link to="/" exact>Home</router-link>
<router-link to="/events" exact>Events<router-link>
...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.