【发布时间】:2020-03-19 20:00:29
【问题描述】:
当我更改路线并转到有 agm-map 的页面时,我无法将窗口滚动到顶部。
我试过使用
<router-outlet (activate)="onActivate($event)"></router-outlet>
然后在onActivate:
onActivate(event) {
window.scroll(0, 0);
}
我也试过
ngAfterViewInit(){
window.scrollTo(0, 0);
}
和
this.router.events.subscribe((evt) => {
if (!(evt instanceof NavigationEnd)) {
return;
}
window.scrollTo(0, 0);
});
在 ngOnInit 内部,但它不起作用:导航到页面时我总是在地图上,而不是在顶部。
【问题讨论】:
标签: angular angular8 angular-routing agm-map