vue.js - VueRouter route should select first child by default -
hi i'm using vue-router 2.5.3 , have following route structure.
path: "/admin", component: require("./views/layouts/masterlayout.vue"), meta: { requiresauth: true }, children: [ { path: 'dashboard', component: require("./views/dashboard.vue"), alias: "/", name: "dashboard" }, { path: 'upload', component: require("./views/upload.vue"), name: "upload", redirect: {name: 'upload.photo'}, children: [ { path: 'photo', component: require("./components/uploaders/imagesuploader.vue"), name: "upload.photo", props: { selected: true, successendpoint: "/api/v1/upload/complete", uploadendpoint: "/api/v1/upload" } }, { path: 'video', component: require("./components/uploaders/videouploader.vue"), name: "upload.video", props: { selected: true, successendpoint: "/api/v1/upload/complete", uploadendpoint: "/api/v1/upload" } } ] },
and have issue configuration, whenever navigate "admin/upload" shows blank page, want show "admin/upload/photo" default if users navigate "admin/upload" how can acheive in vue router?
i've tried defining aliases in both "upload" , in child routes , nothing happened, tried define redirect key in "upload" parent route , again blank page...
i don't quite im going wrong, fact structure has 2 levels of nesting? if that's problem how define these routes using 1 level of nesting?
nevermind everyone, dumb question... (having bad day @ office today)
just add
alias: "/"
to child route want use default...
so in case "photo" might become
{ path: 'photo', component: require("./components/uploaders/imagesuploader.vue"), name: "upload.photo", alias: "/", props: { selected: true, successendpoint: "/api/v1/upload/complete", uploadendpoint: "/api/v1/upload" } },
because want "photo" respond root within "upload" tell respond both upload/"photo" , upload"/" because these nested inside "upload" "upload" route prepended child , it's aliases.
Comments
Post a Comment