Re-render router-view component in Vue

Viewed 422

The best way to re-render a component in Vue is to update its key. But what if I want to re-render a <router-view> component with this setup?

<router-view :key="this.$route.params.slug"></router-view>

The routing is set up to use /item/:slug

If I change the key to force a re-render, all <router-link> elements inside the <router-view> component stop working. I've tried setting a key on a wrapping <keep-alive> element and updating it, but that doesn't re-render the <router-view>.

Any ideas?

Edit: Looks like the issue was this.$route.params.slug, when changed to $route.params.slug everything got back on track.

0 Answers
Related