前几天我解决了无法浏览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 });
}
现在,每次我想访问该特定页面时,我都会传递错误的 Prop 内容,从而引发错误。调用任何其他页面都没有任何问题。 您知道如何解决该问题吗?
提前谢谢你们。
最佳答案
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"
}
});
}
关于javascript - nativescript-vue navigatorTo vue 页面 props 已缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59058257/