Vue路由对象属性 .meta 和 $route.matched 如何详细解析?

更新于
2026-09-28 08:47:23
0阅读来源:SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计566个文字,预计阅读时间需要3分钟。

Vue路由对象属性 .meta 和 $route.matched 如何详细解析?

Vue Router 设置示例:

1.路由全路径:/path/:type

2.真实路径:/path/list

3.path 匹配路径:/path/list

4.fullPath 匹配路由:/path/:type

路由配置如下:const router=new VueRouter({ routes: [ { path: '/foo', component: Foo, children: '' } ]})

$route.fullPath

1 路由是:/path/:type真正路径是:/path/list

2 path匹配路径: /path/list

3 fullPath匹配路由: /path/:type

路由元信息 .meta

const router = new VueRouter({ routes: [ { path: '/foo', component: Foo, children: [ { path: 'bar', component: Bar, // a meta field meta: { requiresAuth: true ,keepAlive:true}//1.权限 2.内存缓存,单页面切换 } ] } ] })

先理解什么是路由记录 : 路由记录就是 routes 配置数组中的对象副本 (还有在 children 数组)。

阅读全文

本文共计566个文字,预计阅读时间需要3分钟。

Vue路由对象属性 .meta 和 $route.matched 如何详细解析?

Vue Router 设置示例:

1.路由全路径:/path/:type

2.真实路径:/path/list

3.path 匹配路径:/path/list

4.fullPath 匹配路由:/path/:type

路由配置如下:const router=new VueRouter({ routes: [ { path: '/foo', component: Foo, children: '' } ]})

$route.fullPath

1 路由是:/path/:type真正路径是:/path/list

2 path匹配路径: /path/list

3 fullPath匹配路由: /path/:type

路由元信息 .meta

const router = new VueRouter({ routes: [ { path: '/foo', component: Foo, children: [ { path: 'bar', component: Bar, // a meta field meta: { requiresAuth: true ,keepAlive:true}//1.权限 2.内存缓存,单页面切换 } ] } ] })

先理解什么是路由记录 : 路由记录就是 routes 配置数组中的对象副本 (还有在 children 数组)。

阅读全文