使用 navigateByUrl 时,queryParams 未反映在 URL 中
queryParams are not reflected in URL while using navigateByUrl
在我的组件中,当我尝试
this.router.navigate([`/courses/`, course.id], {queryParams:{description: course.description}});
导航后,URL有description
个查询参数。
但是,当我尝试这个时,
this.router.navigateByUrl(`/courses/${course.id}`, {queryParams:{description: course.description}});
URL 里面没有 description
查询参数。
在使用 navigateByUrl
时,我是否需要进行更改以反映 URL 中的查询参数? (但是,Angular Documentation 表示 NavigationExtras
对象对于 navigate
和 navigateByUrl
都是相同的。)
在我的组件中,当我尝试
this.router.navigate([`/courses/`, course.id], {queryParams:{description: course.description}});
导航后,URL有description
个查询参数。
但是,当我尝试这个时,
this.router.navigateByUrl(`/courses/${course.id}`, {queryParams:{description: course.description}});
URL 里面没有 description
查询参数。
在使用 navigateByUrl
时,我是否需要进行更改以反映 URL 中的查询参数? (但是,Angular Documentation 表示 NavigationExtras
对象对于 navigate
和 navigateByUrl
都是相同的。)