angular路由跳转navigate

1、不带参数

this.router.navigate(['/custom']);

2、带参数跳转

const params: any = this.validateForm.value;
this.router.navigate(['/custom', params]);
// custom模块接收参数
// 第一种方式
this.router.snapshot.params;
// 第二种方式
this.router.params.subscribe((params) => {
      this.params = params;
    });
this.router.navigate(['/custom'], { queryParams: params});
// custom模块接收参数
this.router.snapshot.queryParams

3、隐藏路由和参数跳转

// skipLocationChange: true 默认为false 不会把新状态记入历史
this.router.navigate(['/custom'], {queryParams: params, skipLocationChange: true});

猜你喜欢

转载自blog.csdn.net/ligaoming_123/article/details/88685600
今日推荐