SAP Spartacus的navigation初始化
2020-12-30 本文已影响0人
华山令狐冲
SAP Spartacus navigation入口:

/**
* Sets up the location change listener and performs the initial navigation.
*/
initialNavigation() {
this.setUpLocationChangeListener();
if (this.navigationId === 0) {
this.navigateByUrl(this.location.path(true), { replaceUrl: true });
}
}
/**
* Navigates to a view using an absolute route path.
*
* @param url An absolute path for a defined route. The function does not apply any delta to the
* current URL.
* @param extras An object containing properties that modify the navigation strategy.
* The function ignores any properties in the `NavigationExtras` that would change the
* provided URL.
*
* @returns A Promise that resolves to 'true' when navigation succeeds,
* to 'false' when navigation fails, or is rejected on error.
*
* @usageNotes
*
* The following calls request navigation to an absolute path.
*
* ```
* router.navigateByUrl("/team/33/user/11");
*
* // Navigate without updating the URL
* router.navigateByUrl("/team/33/user/11", { skipLocationChange: true });
* ```
*
* @see [Routing and Navigation guide](guide/router)
*
*/
navigateByUrl(url, extras = { skipLocationChange: false }) {
if (isDevMode() && this.isNgZoneEnabled && !NgZone.isInAngularZone()) {
this.console.warn(`Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?`);
}
const urlTree = isUrlTree(url) ? url : this.parseUrl(url);
const mergedTree = this.urlHandlingStrategy.merge(urlTree, this.rawUrlTree);
return this.scheduleNavigation(mergedTree, 'imperative', null, extras);
}



RouterStateSnapshot的url字段里包含的electronics-spa/en/USD是怎么来的?

ActivatedRouteSnapshot

array是一个闭包:

此时还没有从后台请求数据,前台怎么知道url应该为electronics-spa/en/USD?
