如何从子组件中获取路线参数(例如,图片中的companyId)?
到目前为止,以下操作无效:
this.companyId = this.route.snapshot.params.companyId;
if (!this.companyId)
this.companyId = this.route.parent.snapshot.params.companyId;
答案 0 :(得分:1)
将选项{paramsInheritanceStrategy: 'always'}
添加到您的Router.forRoot()
。