Vue Router 使用指南
Component Injected 属性
这些属性通过调用 app.use(router)
注入到每个子组件中。
一、$router 对象
在 Vue 实例中,可以通过 $router 访问路由实例。
二、$route 对象
当前激活的路由地址。这个属性是只读的,并且它的属性是不可改变的,但是它可以被观察。https://test.disoo.co/crm/#/ya/records-detail?id=IDC00000052&_t=1668953125158
1. fullPath
- 类型:
string
- 介绍:包括 path、query 和 hash
- 举例:
/ya/records-detail?id=IDC00000052&_t=1668953125158
2. hash
- 类型:
string
- 介绍:已解码 URL 的 hash 部分。总是以 # 开头。如果 URL 中没有 hash,则为空字符串
3. query
- 类型:
Record<string, string | string[]>
- 介绍:从 URL 的 search 部分提取的已解码查询参数的字典
- 举例:
{ "id": "IDC00000052", "_t": 1668953125158 }
4. matched
- 类型:
RouteRecordNormalized[]
- 介绍:与给定路由地址匹配的标准化的路由记录数组
5. meta
- 类型:
RouteMeta
- 介绍:附加到从父级到子级合并(非递归)的所有匹配记录的任意数据
- 举例:
{ "title": "Record Manage" }
6. name
- 类型:
string | symbol | undefined | null
- 介绍:路由记录的名称。如果什么都没提供,则为
undefined
- 举例:
YaRecordDetail
7. params
- 类型:
Record<string, string | string[]>
- 介绍:从 path 中提取的已解码参数字典
8. path
- 类型:
string
- 介绍:编码 URL 的 pathname 部分,与路由地址有关
- 举例:
/ya/records-detail