nativescript-vue / nativescript-vue-navigator

A simple router for NativeScript-Vue, built on top of $navigateTo to simplify routing from within components
MIT License
98 stars 10 forks source link

topmost() is undefined #9

Closed rushairer closed 4 years ago

rushairer commented 5 years ago

The page is set to defaultRoute

import * as frameModule from 'tns-core-modules/ui/frame'

...

mounted() {
        console.log(frameModule.topmost())

....

frameModule.topmost() I got 'undefined'

If not a defaultRoute page, just use this.$navigator.navigate open it, topmost is not 'undefined' now.

rigor789 commented 5 years ago

Can you describe your issue in more detail, steps to reproduce or a sample that shows the issue?

rushairer commented 5 years ago

Example:

main.js

import Vue from 'nativescript-vue'
import App from './App'
import Navigator from 'nativescript-vue-navigator'
import { routes } from './routes'

...
...

// setup routes
Vue.use(Navigator, { routes })

new Vue({
    store,
    render: h => h(App)
}).$start()

App.vue

<template>
    <Navigator class="ns-dark" :defaultRoute="'/welcome'" />
</template>
<script>
...
</script>

Welcome.vue

...
import * as frameModule from 'tns-core-modules/ui/frame'

...

mounted() {
        console.log(frameModule.topmost())

...

console.log(frameModule.topmost()) got undefined

darrenkhouston commented 4 years ago

@rushairer I am also using this plugin and I am able to reference topmost() by importing it as its own module.

import { topmost } from "tns-core-modules/ui/frame"

Then I can reference it below as mounted() { console.log(topmost()); }

rushairer commented 4 years ago

@darrenkhouston Thanks, I will try it.

darrenkhouston commented 4 years ago

@rushairer sure thing. Should also note that calling topmost() directly is deprecated, so import { Frame } from "tns-core-modules/ui/frame" and then calling mounted() { console.log(Frame.topmost()); } is probably the recommended way to do it.

rushairer commented 4 years ago

Thanks