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

2026-04-05 20:069阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

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

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

plaintext$router.fullPath + 1 路径是:/path/:type真实路径是:/path/listpath匹配路径:/path/listfullPath匹配路由:/path/:type路由元素信息.metaconst 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 数组)。

阅读全文

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

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

plaintext$router.fullPath + 1 路径是:/path/:type真实路径是:/path/listpath匹配路径:/path/listfullPath匹配路由:/path/:type路由元素信息.metaconst 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 数组)。

阅读全文