SAP Spartacus navigation入口:
![](https://img.haomeiwen.com/i2085791/a5656c8eea3b5881.png)
/**
* 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);
}
![](https://img.haomeiwen.com/i2085791/b54bd259c71eecf9.png)
![](https://img.haomeiwen.com/i2085791/7fba02d6bc44828b.png)
![](https://img.haomeiwen.com/i2085791/42fb124a36a8a281.png)
RouterStateSnapshot的url字段里包含的electronics-spa/en/USD是怎么来的?
![](https://img.haomeiwen.com/i2085791/f4510b5642d7d89f.png)
ActivatedRouteSnapshot
![](https://img.haomeiwen.com/i2085791/13364ed384539baf.png)
array是一个闭包:
![](https://img.haomeiwen.com/i2085791/929cf2bdd6340ba0.png)
此时还没有从后台请求数据,前台怎么知道url应该为electronics-spa/en/USD?
![](https://img.haomeiwen.com/i2085791/eb57c9f657a9007a.png)
网友评论