Issue
export const routes: RouteRecordRaw[] = [
{
path: '/',
name: 'Main',
component: () => import('~/pages/Main.vue'),
children: [],
},
{
path: '/auth',
name: 'Auth',
component: () => import('~/pages/Auth.vue'),
meta: {
isAuthPage: true,
},
},
{
path: '/movies',
name: 'Movies',
component: () => import('~/pages/Movies.vue'),
meta: {
isAuthPage: true,
},
},
{
path: '/tv-shows',
name: 'TVShows',
component: () => import('~/pages/TVShows.vue'),
meta: {
isAuthPage: true,
},
},
]
I expected type Pages = 'Main' | 'Auth' | 'Movies' | 'TVShows
Solution
What do you mean by you expected? Do you want to create this type? You could do that like this:
export const routes = [
{
path: '/',
name: 'Main',
component: () => import('~/pages/Main.vue'),
children: [],
},
{
path: '/auth',
name: 'Auth',
component: () => import('~/pages/Auth.vue'),
meta: {
isAuthPage: true,
},
},
{
path: '/movies',
name: 'Movies',
component: () => import('~/pages/Movies.vue'),
meta: {
isAuthPage: true,
},
},
{
path: '/tv-shows',
name: 'TVShows',
component: () => import('~/pages/TVShows.vue'),
meta: {
isAuthPage: true,
},
},
] as const
type Pages = typeof routes[number]["name"]
Answered By - oliverwebr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.