1. 程式人生 > >Angular4_在頁面上返回指定位置,錨點追蹤

Angular4_在頁面上返回指定位置,錨點追蹤

官方給的是

Fragment 

但是好像不工作啊,最近在issues上看到的解決方案

<a (click)="goTo('destination')">Go TO DIV</a>

<div id="destination">
    <h2>Destination</h2>
</div>

Then in your component:

goTo(location: string): void {
    window.location.hash = ''; 
    window.location.hash = location;
}

地址:

https://github.com/angular/angular/issues/13636

https://github.com/angular/angular/issues/6595