Skip to content
Advertisement

Vue $route is not defined

I’m learning Vue router. And I want to made programmatic navigation without using <router-link> in templates file. My router and view:

JavaScript

So by default I push to ‘allVideos’ route and inside that component I have a button and method for redirecting to ”editVideo’ button:

JavaScript

method:

JavaScript

It works fine. But when I try to get id inside a VideoEdit component using $route.params.id I got error Uncaught ReferenceError: $route is not defined

Maybe it’s because I’m not using npm for now just a cdn version of Vue and Vuerouter. Any solutions? Thanks!

Updated: btw in Vue dev tool I see $route instance inside the component

Updated:

JavaScript

Advertisement

Answer

Thanks to Sandeep Rajoria

we found solution, need to use this.$route except $route inside a component

Advertisement