Navigation
有关导航操作的信息。使用 Router.getCurrentNavigation() 方法检索最新的导航对象。
Information about a navigation operation. Retrieve the most recent navigation object with the Router.getCurrentNavigation() method .
type Navigation = {
id: number;
initialUrl: string | UrlTree;
extractedUrl: UrlTree;
finalUrl?: UrlTree;
trigger: 'imperative' | 'popstate' | 'hashchange';
extras: NavigationExtras;
previousNavigation: Navigation | null;
};
说明
id :当前导航的唯一标识符。
id : The unique identifier of the current navigation.
initialUrl:在导航前传给
Router#navigateByUrl()
调用的目标 URL。这是路由器解析或对其应用重定向之前的值。initialUrl : The target URL passed into the
Router#navigateByUrl()
call before navigation. This is the value before the router has parsed or applied redirects to it.extractedUrl:使用
UrlSerializer.extract()
解析后的初始目标 URL。extractedUrl : The initial target URL after being parsed with
UrlSerializer.extract()
.finalUrl:应用重定向之后提取的 URL。该 URL 可能不会立即可用,因此该属性也可以是
undefined
。在RoutesRecognized
事件触发后进行设置。finalUrl : The extracted URL after redirects have been applied. This URL may not be available immediately, therefore this property can be
undefined
. It is guaranteed to be set after theRoutesRecognized
event fires.trigger:表明这次导航是如何触发的。 -- 'imperative'-- 由
router.navigateByUrl
或router.navigate
触发。 -- 'popstate'-- 由 popstate 事件触发。 -- 'hashchange'-- 由 hashchange 事件触发。trigger : Identifies how this navigation was triggered. -- 'imperative'--Triggered by
router.navigateByUrl
orrouter.navigate
. -- 'popstate'--Triggered by a popstate event. -- 'hashchange'--Triggered by a hashchange event.extras:一个
NavigationExtras
选项对象,它控制用于此导航的策略。extras : A
NavigationExtras
options object that controlled the strategy used for this navigation.previousNavigation:先前成功的
Navigation
对象。只有一个先前的导航可用,因此该先前的Navigation
对象自己的previousNavigation
值为null
。previousNavigation : The previously successful
Navigation
object. Only one previous navigation is available, therefore this previousNavigation
object has anull
value for its ownpreviousNavigation
.