1. 程式人生 > >angular瀏覽器不能點選返回

angular瀏覽器不能點選返回

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import {Location} from '@angular/common';//這個要寫
@Component({
  selector: 'app-flash',
  templateUrl: './flash.component.html',
  styleUrls: ['./flash.component.css']
})
export class FlashComponent implements OnInit {
//這個要寫
  constructor(public router:Router,public location:Location) { }

  ngOnInit() {
  //這個要寫
    this.location.replaceState('/main');
    setTimeout(()=>{this.router.navigateByUrl('/main')}, 3000);
    
  }
  jumpNow(){
    this.router.navigateByUrl('/main')
  }
}