angular 取路由参数进行判断

import { Location } from ‘@angular/common’
import {Router} from ‘@angular/Router’
constructor(private location:Location,private router:Router){
    router.events.pipe(filter((event)=>event instanceof NavigationEnd)).subscrible(event=>{
    event.url当前路由信息(不包含自动跳转的)
    event.urlAfterRedirects 当前路由详细信息(暂时自动跳转)
  })
} 

猜你喜欢

转载自www.cnblogs.com/lskzj/p/11752789.html