Bat*_*eIO 6 routing router angularjs angular-routing angular
this.subscription = this.router.events.subscribe((event:Event) => {
console.log(event.url); ##### Error : Property 'url' does not exist on type 'Event'.
}
Run Code Online (Sandbox Code Playgroud)
Typescript无法识别Angular Router中内置的Event类型的属性.tsd上有什么东西我可以用来解决这个问题吗?Event是NaviagationEnd,NavigationStart类的超类
你必须import { Event } from @angular/router;.尝试将控制台移动到if具有条件的块中.
this.subscription = this.router.events.subscribe((event:Event) => {
if(event instanceof NavigationEnd ){
console.log(event.url);
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6865 次 |
| 最近记录: |