1
votes

I am newly working with NativeScript and I don't understand how to navigate pages/views. Unfortunately, it appears that vue-router is still not supported so I am looking at using manual routing. However, I have multiple vue components in app\components and do not want to put them all in one vue the way the example shows.

I have this in my first page view:

<script>
import pageB from "./PageB";

export default {
    methods: {
        onButtonTap() {
            //console.log("Page B Button was pressed");
            this.$navigateTo(pageB);
        }
    },
    created() {},

    data() {
        return {};
    },
    mounted() {}
};
</script>

but when I click the button I get a message:

[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

I noticed that the error references the desired page as javascript: PageB.js even thought that doesn't exist. Does this mean that the routing cannot work with vue components here?

If anyone can point me to an example of a multi vue.file example for NativeScript, maybe that will help me figure this out.

2

2 Answers

0
votes

used const pageB = require("./PageB").default;

instead of import pageB from "./PageB";

0
votes

Something I didn't understand when first being introduced to NS navigation was that all navigation takes place inside a element. Not sure that's your issue, but maybe give it a quick check. A simple one frame example could be:

<template>
  <Frame>
    <PageA />
  </Frame>

and then navigate inside PageA to PageB like your example shows.