Angular 路由器导航不更新连续请求的 url 参数

Angular router navigate does not update url params for continuous request

我正在尝试使用路由器导航更新查询参数

updateURL(queryParams){
        this.router.navigate(['path], {
            relativeTo: this.route,
            queryParams: queryParams,
            queryParamsHandling: 'merge',
            skipLocationChange: false
        });
}

/** Wont Work 
updateURL(queryParams);
updateURL(queryParams);
updateURL(queryParams);

/** Will Work
updateURL(queryParams);
// wait
updateURL(queryParams);
// wait
updateURL(queryParams)

当连续调用此方法更新 URL 查询参数时,angular 不会更新 url。 如何处理它以便 angular 更新 url 即使在进行顺序调用时也是如此

从文档中保证您将不得不等待下一次更新

navigate(commands: any[], extras: NavigationExtras = { skipLocationChange: false }): Promise<boolean>

你能试试这个吗

async updateURL(queryParams){
       await this.router.navigate(['path], {
            relativeTo: this.route,
            queryParams: queryParams,
            queryParamsHandling: 'merge',
            skipLocationChange: false
        });
}

async UpdateQueryParam() {
 await updateURL(queryParams);
  await updateURL(queryParams);
  await updateURL(queryParams)
}