In single-page apps that use the Vue Router, it is common to create a path parameter that changes the behavior of a route. A common problem occurs when a user alters the path manually in the address bar.

If this is a common problem in your app, you can set your entire router-view to re-render when its path changes by providing a key property: With the above, you won’t need to use the beforeRouteUpdate() hook, and can directly access the now-reactive this.$route.params.myVar property. The only problem with this method is that every path in that router will update in the case of a path change.

Take game-like coding courses on Qvault ClassroomSubscribe to our Newsletter for more educational articles

Related Articles