老师,请问angular路由传参可以使用params形式吗?
来源:4-11 路由 URL 和参数 下(3)
会游泳的兔子先森
2020-08-31
就是让传递的参数不显示在url中,就像Vue中的params一样。
比如我需要传递一个base64字符串参数,因为那样太长了。
除了引入storage或者ngrx / redux之类的,请问有解决办法吗
写回答
1回答
-
首先 angular 中提倡的是采用 service 传递复杂参数,但路由传递当然也是可能的,通过路由的 state 传递即可
this.router.navigate(['xxx'], { state: { example: 'bar' } });然后使用
constructor(private router: Router) { console.log(this.router.getCurrentNavigation().extras.state.example); }012020-08-31
相似问题