3
this.subscription = this.router.events.subscribe((event:Event) => {
console.log(event.url); ##### Error : Property 'url' does not exist on type 'Event'.
}
Typescript不能识别内置于Angular Router中的类型Event的属性。 tsd上有什么我可以用来解决这个问题的吗?事件是超类的类NaviagationEnd的,NavigationStart对于Angular2导航类型“事件”,Property'url'不存在导航EndEnd事件
有你导入的事件形成@角/路由器。尝试移动控制台在if条件与条件如果(事件instanceof NavigationEnd) –
你得到它!谢谢,林新这个打字稿的东西 – BathgateIO
更新了这个答案。 –