Why isn't router.currentRoute.path reactive?
The router
object created via new VueRouter
is not reactive because Vue has no way to know to watch and update any object outside of its scope.
Passing router
in the Vue
config object is what allows the current route to be watched, but you need to reference it via this.$route
:
if (this.$route.path == "/foo") {
...
}
You can also access the entire router
object via this.$router
, but its data is not reactive.