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

RouterEvent

路由器相关事件的(而不是关于特定路由的)基类。对于任何指定的导航,RouterEvent 只会触发一次。

Base for events the router goes through, as opposed to events tied to a specific route. Fired one time for any given navigation.

查看"说明"...

      
      class RouterEvent {
  constructor(id: number, url: string)
  id: number
  url: string
}
    

参见

说明

以下代码演示了一个类是如何订阅路由器事件的。

The following code shows how a class subscribes to router events.

      
      class MyService {
  constructor(public router: Router, logger: Logger) {
    router.events.pipe(
       filter((e: Event): e is RouterEvent => e instanceof RouterEvent)
    ).subscribe((e: RouterEvent) => {
      logger.log(e.id, e.url);
    });
  }
}
    

构造函数

      
      constructor(id: number, url: string)
    
参数
id number

A unique ID that the router assigns to every router navigation.

url string

The URL that is the destination for this navigation.

属性

属性说明
id: number声明在构造函数中

A unique ID that the router assigns to every router navigation.

url: string声明在构造函数中

The URL that is the destination for this navigation.