Angular 2激活路线
发布时间:2020-12-17 18:11:35 所属栏目:安全 来源:网络整理
导读:也许我错过了什么? 在Angular 2组件中,我只是想获得完整的激活路径. 我不想使用location.href. 我的构造函数如下: constructor(private route: ActivatedRoute) {} 在ngOnInit()中我试过: this.route.data.urlthis.route.snapshot 都没有工作. 任何帮助都
也许我错过了什么?
在Angular 2组件中,我只是想获得完整的激活路径. 我不想使用location.href. 我的构造函数如下: constructor(private route: ActivatedRoute) {} 在ngOnInit()中我试过: this.route.data.url this.route.snapshot 都没有工作. 任何帮助都非常感谢. 解决方法
您不需要使用ActivatedRoute,您需要使用
Router以字符串形式查询当前URL:
constructor(r: Router) { console.log(r.url); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |