I want to pick the nested type in the Vue Router.

Asked 1 years ago, Updated 1 years ago, 464 views

I want to take only matched meta from the vue-router Route type.
Specifically, I was able to take out the matched as below, but I don't know how to take out only meta and get an error.
I would appreciate it if you could tell me how to resolve it.

const to:Pick<Route, 'fullPath' | 'path' | 'matched' > = {
  fullPath: '/home',
  path: '/home',
  matched: [{meta:{isPublic:true}},
};
Type '{meta:{isPublic:true;};} 'is missing the following properties from type 'RouteRecord': path, regex, components, instances, propsts (2739)

vue.js typescript

2022-09-30 22:01

1 Answers

 type Meta=Route ['matched'] [number] ['meta']

It can be taken out by .
However, this type has been exported in the first place, so

import type {RouteMeta} from 'vue-router'

There's a good enough explanation.


2022-09-30 22:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.