angualr版本:
在路由传参时有三种方式:
一:在查询参数中传递数据,例如:
传递:/product?id=1&name=aaa => 接收:在路由的目标组件中 使用 ActivatedRoute.queryParams[id]




二:在路由路径中传递数据,例如:
{path:/product/:id} => /product/1 => ActivatedRoute.params[id]
在 routing.module 的路由配置中:




三:在路由配置中传递数据,例如:
{path:/product,component:ProductComponent,data:[{isFinished:true}] } => ActivatedRoute.data[0][isFinished]
网友评论