【发布时间】:2021-06-06 16:12:02
【问题描述】:
我的 ns-vue 应用程序在观看时遇到问题。我有基于此抽屉导航模板https://plugins.nativescript.rocks/plugin/@nativescript/template-drawer-navigation-vue 的应用程序。我想为整个应用程序使用地理定位,所以我把这个模块放到 DrawerContent.vue 中。 在这个文件中,我将 props 传递给其他模块:
onNavigationItemTap(component) {
this.$navigateTo(component, {
clearHistory: true,
props:{
latitude: this.latitude,
longitude: this.longitude,
}
});
utils.closeDrawer();
}
纬度和经度会定期更新。
在 Home.vue 我有:
props:['latitude','longitude'],
...
....
watch:{
latitude:()=>{
console.log('LAT change detected')
}
}
但这不起作用。我尝试了整个网络的很多选项,例如:
watch: {
$props: {
handler() {
this.parseData();
},
deep: true,
immediate: true,
}
}
或
watch:{
'$props':()=>{
......
}
}
但仍然无法正常工作。
请帮忙,谢谢
【问题讨论】:
标签: nativescript watch nativescript-vue vue-props