Contains the information about a route associated with a component loaded in an outlet at a particular moment in time. ActivatedRouteSnapshot can also be used to traverse the router state tree.
包含与当前组件相关的路由的当前瞬间信息。ActivatedRoute 也可用于遍历路由器的状态树。 ActivatedRouteSnapshot 也能用于遍历路由器状态树。
说明 @Component ({templateUrl:'./my-component.html'}) class MyComponent { constructor(route: ActivatedRoute ) { const id: string = route.snapshot.params.id; const url: string = route.snapshot.url.join(''); const user = route.snapshot.data.user; } } 属性 属性名 类型 说明 routeConfigRoute | null只读 The configuration used to match this route
用于匹配当前路由的配置项
urlUrlSegment []The URL segments matched by this route
与当前路由匹配的 URL 段
paramsParams The matrix parameters scoped to this route
此路由范围内的矩阵参数(;)
queryParamsParams The query parameters shared by all the routes
所有路由共享的查询参数(?)
fragmentstringThe URL fragment shared by all the routes
所有路由共享的 URL 片段(#)
dataData The static and resolved data of this route
此路由的静态数据和已解析数据
outletstringThe outlet name of the route
此路由的出口(outlet)名称
componentType <any> | string | nullThe component of the route
此路由对应的组件
rootActivatedRouteSnapshot 只读 The root of the router state
路由器状态树的根节点
parentActivatedRouteSnapshot | null只读 The parent of this route in the router state tree
在路由器状态树中,当前路由的父路由
firstChildActivatedRouteSnapshot | null只读 The first child of this route in the router state tree
在路由器状态树中,当前路由的第一个子路由
childrenActivatedRouteSnapshot []只读 The children of this route in the router state tree
在路由器状态树中,当前路由的所有子路由
pathFromRootActivatedRouteSnapshot []只读 The path from the root of the router state tree to this route
在路由器状态树中从根节点开始到当前路由的完整路径
paramMapParamMap 只读 queryParamMapParamMap 只读
方法 toString(): string 参数 没有参数。
返回值 string