如何从 Angular 9 中的 url 中删除哈希并将浏览器中的 url 更新为当前的 url

How to remove hash from url in Angular 9 and also update the url in the browser to the current url

此题与不同。

我需要知道如何从 url 中删除哈希并在浏览器中更新 url。

@NgModule({
  imports: [RouterModule.forRoot(routes, { anchorScrolling: 'enabled', useHash: false, scrollPositionRestoration:'enabled' })],


"@angular/router": "~9.1.2",

当前行为:

Url 在浏览器中:/something

用户点击次数:<a [routerLink]="['/home']" fragment="home" >Home</a>

浏览器导航到:/home

Url 在浏览器中:/home#home

页面滚动到:#home

使用上述问题的答案时的行为:

Url 在浏览器中:/something

用户点击次数:<a [routerLink]="['/home']" fragment="home" skipLocationChange>Home</a>

浏览器导航到:/home

Url 在浏览器中:/something

页面滚动到:#home

期望的行为:

Url 在浏览器中:/something

用户点击次数:<a [routerLink]="['/home']" fragment="home" >Home</a>

浏览器导航到:/home

Url in browser: /home // 期望的行为是当前 url 在浏览器中显示时没有散列。

页面滚动到:#home

https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

To save your and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow.

这个问题的答案是:不要使用不受支持的框架。