Reputation: 129
i solved the problem a few days ago that I couldn't navigate through vue pages. After the problem was gone I made a mistake by trying to pass a wrong key value to the vue page I was redirecting to.
Here is there error when the page navigateTo method is executed on a specific vue page:
JS: 'There was an error!' [ReferenceError: test is not defined]
This is the method which redirects with props:
import Vue from "nativescript-vue";
import router from "./router";
Vue.prototype.$changePage = function(to, props, params) {
this.$navigateTo(router[to], {
props,
...params // clearHistory, backstackVisible
});
}
The way I called the function is:
goToHome(prop) {
this.$changePage( aspecificpage, { test:'hello' }, { clearHistory: true });
}
Now every time I want to access that specific page I have passed a wrong props content throws an error. Any other page is being called without any problems. Do you have any clue how the problem can be solved?
Thank you in advance guys.
Upvotes: 0
Views: 264
Reputation: 1414
main.js
import Vue from 'nativescript-vue'
import Bootup from './components/App'
import Select from './components/Select/StationSelect'
import RouteDetails from "./components/Route/SingleTrain/Details"
const router = {
Bootup: Bootup,
Select: Select,
RouteDetails: RouteDetails
};
Vue.prototype.$router = router;
Vue.prototype.$changePage= function (to, props = null) {
this.$navigateTo(this.$router[to], props)
};
someVuePage.vue
goToHome() {
this.$changePage('MultiRouteDetails', {
props: {
test: "hello"
}
});
}
Upvotes: 1