angular瀏覽器不能點選返回
阿新 • • 發佈:2018-12-15
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') } }