angular 路由切换浏览器记住滚动条的位置

问题:angular 路由切换浏览器记住滚动条的位置

解决:

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

declare var $: any;

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  title = 'app';
  constructor(public router: Router) {

  }

  ngOnInit() {

    this.router.events
      .subscribe((event) => {
        $(window).scrollTop(0);

      });


  }


}

猜你喜欢

转载自blog.csdn.net/xif3681/article/details/81167517