nativescript-vue navigateTo vue 页面道具被缓存
nativescript-vue navigateTo vue page props is cached
前几天解决了vue页面无法导航的问题。
问题消失后,我犯了一个错误,试图将错误的键值传递到我重定向到的 vue 页面。
在特定vue页面执行页面navigateTo方法时出现错误:
JS: 'There was an error!' [ReferenceError: test is not defined]
这是使用 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
});
}
我调用函数的方式是:
goToHome(prop) {
this.$changePage( aspecificpage, { test:'hello' }, { clearHistory: true });
}
现在每次我想访问我传递了错误的道具内容的特定页面时都会抛出错误。正在调用任何其他页面,没有任何问题。
您知道如何解决这个问题吗?
提前谢谢大家。
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"
}
});
}
前几天解决了vue页面无法导航的问题。 问题消失后,我犯了一个错误,试图将错误的键值传递到我重定向到的 vue 页面。
在特定vue页面执行页面navigateTo方法时出现错误:
JS: 'There was an error!' [ReferenceError: test is not defined]
这是使用 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
});
}
我调用函数的方式是:
goToHome(prop) {
this.$changePage( aspecificpage, { test:'hello' }, { clearHistory: true });
}
现在每次我想访问我传递了错误的道具内容的特定页面时都会抛出错误。正在调用任何其他页面,没有任何问题。 您知道如何解决这个问题吗?
提前谢谢大家。
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"
}
});
}