填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

BaseRouteReuseStrategy

此基本路由复用策略仅在匹配的路由器配置完全相同时复用路由。这样可以防止仅在片段或查询参数发生更改时销毁和重新创建组件(也就是复用现有组件)。

This base route reuse strategy only reuses routes when the matched router configs are identical. This prevents components from being destroyed and recreated when just the fragment or query parameters change (that is, the existing component is reused).

查看"说明"...

      
      abstract class BaseRouteReuseStrategy implements RouteReuseStrategy {
  shouldDetach(route: ActivatedRouteSnapshot): boolean
  store(route: ActivatedRouteSnapshot, detachedTree: DetachedRouteHandle): void
  shouldAttach(route: ActivatedRouteSnapshot): boolean
  retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null
  shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean
}
    

说明

此策略不存储任何路由供以后复用。

This strategy does not store any routes for later reuse.

Angular 默认使用此策略。

Angular uses this strategy by default.

它可以用作自定义路由复用策略的基类,即,你可以创建自己的类来扩展 BaseRouteReuseStrategy

It can be used as a base class for custom route reuse strategies, i.e. you can create your own class that extends the BaseRouteReuseStrategy one.

方法

给定的路由是否应该分离以便以后复用。BaseRouteReuseStrategy 始终返回 false。

Whether the given route should detach for later reuse. Always returns false for BaseRouteReuseStrategy.

      
      shouldDetach(route: ActivatedRouteSnapshot): boolean
    
参数
route ActivatedRouteSnapshot
返回值

boolean

无操作;永远不会存储该路由,因为此策略永远不会分离路由以供以后复用。

A no-op; the route is never stored since this strategy never detaches routes for later re-use.

      
      store(route: ActivatedRouteSnapshot, detachedTree: DetachedRouteHandle): void
    
参数
route ActivatedRouteSnapshot
detachedTree DetachedRouteHandle
返回值

void

返回 false ,表示路由(及其子树)从不重新连接

Returns false, meaning the route (and its subtree) is never reattached

      
      shouldAttach(route: ActivatedRouteSnapshot): boolean
    
参数
route ActivatedRouteSnapshot
返回值

boolean

返回 null,因为此策略不存储路由供以后复用。

Returns null because this strategy does not store routes for later re-use.

      
      retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null
    
参数
route ActivatedRouteSnapshot
返回值

DetachedRouteHandle | null

确定是否应复用路由。当将来的路由配置和当前的路由配置相同时,此策略将返回 true

Determines if a route should be reused. This strategy returns true when the future route config and current route config are identical.

      
      shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean
    
参数
future ActivatedRouteSnapshot
curr ActivatedRouteSnapshot
返回值

boolean