我刚开始使用 NativeScript,但我不明白如何导航页面/视图。不幸的是,vue-router 似乎仍然不受支持,所以我正在考虑使用手动路由。但是,我在 app\components 中有多个 vue 组件,并且不想像示例所示的那样将它们全部放在一个 vue 中。
我的第一页视图中有这个:
<script>
import pageB from "./PageB";
export default {
methods: {
onButtonTap() {
//console.log("Page B Button was pressed");
this.$navigateTo(pageB);
}
},
created() {},
data() {
return {};
},
mounted() {}
};
</script>
但是当我单击按钮时,我收到一条消息:
[iPhone 8+]: The Preview app has terminated unexpectedly. Please run it again to get a detailed crash report. [iPhone 8+]: '{NSVue (Vue:
2.5.17 | NSVue: 2.0.0)} -> CreateElement(nativelabel)' 2018-10-28 13:54:15.823 nsplaydev[1294:331774] -[TNSLabel useLayoutToLayoutNavigationTransitions]: unrecognized selector sent to instance 0x10a909f00 2018-10-28 13:54:15.826 nsplaydev[1294:331774] PlayLiveSync: Uncaught Exception 2018-10-28 13:54:15.827 nsplaydev[1294:331774] PlayLiveSync: Sending crash report 2018-10-28 13:54:19.831 nsplaydev[1294:331774] *** JavaScript call stack: ( 0 pushViewControllerAnimated@[native code] 1 pushViewControllerAnimated@file:///app/tns_modules/tns-core-modules/ui/frame/frame.js:343:61 2
_navigateCore@file:///app/tns_modules/tns-core-modules/ui/frame/frame.js:116:56 3 performNavigation@file:///app/tns_modules/tns-core-modules/ui/frame/frame-common.js:235:27 4
_processNextNavigationEntry@file:///app/tns_modules/tns-core-modules/ui/frame/frame-common.js:227:39 5 navigate@file:///app/tns_modules/tns-core-modules/ui/frame/frame-common.js:131:41 6 navigate@file:///app/tns_modules/nativescript-vue/dist/index.js:6494:24 7 navigate@[native code] 8 @file:///app/tns_modules/nativescript-vue/dist/index.js:13221:26 9 initializePromise@:1:11 10 Promise@[native code] 11 $navigateTo@file:///app/tns_modules/nativescript-vue/dist/index.js:13198:25 12 onButtonTap@file:///app/components/PageB.js:20:29 13 onButtonTap@[native code]
2018-10-28 13:54:19.831 nsplaydev[1294:331774] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TNSLabel useLayoutToLayoutNavigationTransitions]: unrecognized selector sent to instance 0x10a909f00'
*** First throw call stack:
(0x226727ef8 ....)
libc++abi.dylib: terminating with uncaught exception of type NSException
2018-10-28 13:54:19.832 nsplaydev[1294:331774] PlayLiveSync: Uncaught Exception
我注意到错误将所需页面引用为 javascript: PageB.js 甚至认为它不存在。这是否意味着路由不能在这里与 vue 组件一起使用?
如果有人可以向我指出 NativeScript 的多 vue.file 示例,也许这将帮助我解决这个问题。