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

NavigationStart

代表导航开始时触发的事件。

An event triggered when a navigation starts.

      
      class NavigationStart extends RouterEvent {
  constructor(id: number, url: string, navigationTrigger: "imperative" | "popstate" | "hashchange" = 'imperative', restoredState: { [k: string]: any; navigationId: number; } = null)
  navigationTrigger?: 'imperative' | 'popstate' | 'hashchange'
  restoredState?: {...}
  toString(): string

  // 继承自 router/RouterEvent
  constructor(id: number, url: string)
  id: number
  url: string
}
    

构造函数

      
      constructor(id: number, url: string, navigationTrigger: "imperative" | "popstate" | "hashchange" = 'imperative', restoredState: { [k: string]: any; navigationId: number; } = null)
    
参数
id number
url string
navigationTrigger "imperative" | "popstate" | "hashchange"
可选. 默认值是 `'imperative'`.
restoredState object
可选. 默认值是 `null`.

属性

属性说明
navigationTrigger?: 'imperative' | 'popstate' | 'hashchange'

标识触发本次导航的调用或事件。imperative 触发器来自对 router.navigateByUrl()router.navigate() 的调用。

Identifies the call or event that triggered the navigation. An imperative trigger is a call to router.navigateByUrl() or router.navigate().

参见:

restoredState?: { [k: string]: any; navigationId: number; } | null

当导航是由 popstate 事件触发的时,这里就是先前提供给 pushState 的导航状态,否则为 null。

The navigation state that was previously supplied to the pushState call, when the navigation is triggered by a popstate event. Otherwise null.

状态对象由 NavigationExtras 定义,并包含任何由开发人员定义的状态值以及路由器分配给每次路由器转换/导航的唯一 ID。

The state object is defined by NavigationExtras, and contains any developer-defined state value, as well as a unique ID that the router assigns to every router transition/navigation.

从路由器的角度来看,路由器从来不会“后退”。当用户单击浏览器中的后退按钮时,将创建一个新的导航 ID。

From the perspective of the router, the router never "goes back". When the user clicks on the back button in the browser, a new navigation ID is created.

使用此先前状态对象中的 ID 可以区分新创建的状态和由 popstate 事件返回的状态,以便可以恢复某些记忆状态,例如滚动位置。

Use the ID in this previous-state object to differentiate between a newly created state and one returned to by a popstate event, so that you can restore some remembered state, such as scroll position.

方法

      
      toString(): string
    
参数

没有参数。

返回值

string