美文网首页
Angular Routes 参数详解

Angular Routes 参数详解

作者: 柳源居士 | 来源:发表于2018-10-31 22:45 被阅读108次

Route 接口:

interface Route {
  path?: string
  pathMatch?: string
  matcher?: UrlMatcher
  component?: Type<any>
  redirectTo?: string
  outlet?: string
  canActivate?: any[]
  canActivateChild?: any[]
  canDeactivate?: any[]
  canLoad?: any[]
  data?: Data
  resolve?: ResolveData
  children?: Routes
  loadChildren?: LoadChildren
  runGuardsAndResolvers?: RunGuardsAndResolvers
}

Routes是Route的数组 Route[]。

type Routes = Route[];

说明:

以下说明来自官网,更详细的内容,可以去官网看。

  • path 是一个用于路由匹配 DSL 中的字符串。

  • path is a string that uses the route matcher DSL.


  • pathMatch是一个用来指定路由匹配策略的字符串。

  • pathMatch is a string that specifies the matching strategy.


  • matcher 定义了一个用于路径匹配的自定义策略,指定了它就会代替 path 和 pathMatch。

  • matcher defines a custom strategy for path matching and supersedes path and pathMatch.


  • component 是一个组件类型。

  • component is a component type.


  • redirectTo 是一个 URL 片段,它将会代替当前匹配的 URL 片段。

  • redirectTo is the url fragment which will replace the current matched segment.


  • outlet 是该组件要放进的出口的名字。

  • outlet is the name of the outlet the component should be placed into.


  • canActivate 是一个 DI 令牌的数组,用于查阅 CanActivate 处理器,欲知详情,参见 CanActivate。

  • canActivate is an array of DI tokens used to look up CanActivate handlers. See CanActivate for more info.


  • canActivateChild 是一个 DI 令牌的数组,用于查阅 CanActivateChild 处理器,欲知详情,参见 CanActivateChild。

  • canActivateChild is an array of DI tokens used to look up CanActivateChild handlers. See CanActivateChild for more info.


  • canDeactivate 是一个 DI 令牌的数组,用于查阅 CanDeactivate 处理器,欲知详情,参见 CanDeactivate。

  • canDeactivate is an array of DI tokens used to look up CanDeactivate handlers. See CanDeactivate for more info.


  • canLoad 是一个 DI 令牌的数组,用于查阅 CanLoad 处理器,欲知详情,参见 CanLoad。

  • canLoad is an array of DI tokens used to look up CanLoad handlers. See CanLoad for more info.


  • data 是一个可通过 ActivatedRoute 提供给组件的附加数据。

  • data is additional data provided to the component via ActivatedRoute.


  • resolve 是一个 DI 令牌的映射表,用于查阅数据解析器。欲知详情,参见 Resolve。

  • resolve is a map of DI tokens used to look up data resolvers. See Resolve for more info.


  • runGuardsAndResolvers 定义了路由守卫和解析器的运行时机。默认情况下,它们只会在路由的矩阵参数(#)变化时才会执行。 当设置为 paramsOrQueryParamsChange 时,它们在查询参数(?)变化时也会执行。当设置为 always 时,它们每次都会执行。

  • runGuardsAndResolvers defines when guards and resolvers will be run. By default they run only when the matrix parameters of the route change. When set to paramsOrQueryParamsChange they will also run when query params change. And when set to always, they will run every time.


  • children 是一个子路由定义构成的数组。

  • children is an array of child route definitions.


  • loadChildren 是一个用于惰性加载子路由的引用。欲知详情,参见 LoadChildren。

  • loadChildren is a reference to lazy loaded child routes. See LoadChildren for more info.


相关文章

网友评论

      本文标题:Angular Routes 参数详解

      本文链接:https://www.haomeiwen.com/subject/hhxoaftx.html