NativeScript-Vue-NavigatorisasimplerouterimplementationthatissuitableforNativeScript-Vue.
QuickStart$npminstall--savenativescript-vue-navigator//main.jsimportVuefrom'nativescript-vue'...+importNavigatorfrom'nativescript-vue-navigator'+import{routes}from'./routes'+Vue.use(Navigator,{routes})newVue({-render:h=>h('frame',App),+render:h=>h(App),}).$start()//routes.jsimportHomePagefrom'./components/HomePage'importLoginPagefrom'./components/LoginPage'exportconstroutes={'/home':{component:HomePage,},'/login':{component:LoginPage,},}//App.vue<template>+<Navigator:defaultRoute="isLoggedIn?'/home':'/login'"/></template>Attachingextradatatoaroute//routes.jsimportHomePagefrom'./components/HomePage'importLoginPagefrom'./components/LoginPage'exportconstroutes={'/home':{component:HomePage,+//weareusing`meta`asagoodpractice,butyouarefreetousesomethingelse+meta:{needsAuth:true}},'/login':{component:LoginPage,+meta:{needsAuth:false}},}点击空白处退出提示
评论