填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫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