emiliogrv / nativescript-vue-router

A simple router implementation that is suitable for NativeScript-Vue.
14 stars 1 forks source link

$router object broken #1

Open robertoandres24 opened 5 years ago

robertoandres24 commented 5 years ago

the idea seems good and nice to organize routes, but in the current state of repo, if I clone, install and try to routing from a component, the app brokes and give me the next error Property or method "$router" is not defined on the instance but referenced during render for any reason the object $router doesnt lives in Vue prototype

xfront commented 5 years ago

same problem as you!

emiliogrv commented 5 years ago

Hi @robertoandres24, @xfront what version of NS-Vue are you using?

Also, please check:

zschuessler commented 5 years ago

I had this issue too. I believe I ran into two causes for this issue:

  1. Unsure why, but I am not able to set Vue instance properties. Instead of doing Vue({ router }) I had to set the $router variable on the prototype like this: Vue.prototype.$router = router
  2. I'm pretty sure there may have also been a namespace collision with @vue/devtools, which is very commonly installed with the default vue template installer. Removing that package allowed the router to work as intended, but I'm unsure if rebuilding my platforms folder resolved this, or if removing the package resolved this. (Leaning towards it was removing the plugin)

After setting the prototype and having the devtools gone it works as expected.