Angular 路由传参

725 阅读1分钟

Angular 路由传参 - 参数不显示在url


1. 传参

this.router.navigateByUrl('/reporting/view/' + res.data, {state:{key: 1}});

2.获取参数

const a = this.router.getCurrentNavigation().extras.state && this.router.getCurrentNavigation().extras.state.key