topmost() is undefined
rushairer opened this issue · 6 comments
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.
Can you describe your issue in more detail, steps to reproduce or a sample that shows the issue?
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
@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()); }
@darrenkhouston Thanks, I will try it.
@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.
Thanks