You need to enable JavaScript to run this app. 如何在app routing module中为同一组件配置两条不同访问路径
优惠活动
大模型
产品
解决方案
定价
更多

如何在app routing module中为同一组件配置两条不同访问路径

同组件多路由参数匹配配置方法

如果需要在同一个组件中接收不同数量的路由参数、执行不同业务逻辑,可以直接在路由模块中为同一组件注册多个不同参数规则的路径,参考配置如下:

{path:'Generatereport/:state/:city/:status/:financedBy',component:GeneratereportComponent},
{path:'Generatereport/:state',component:GeneratereportComponent}

配置完成后直接在组件内监听路由参数的变化,判断拿到的参数数量、类型,调用对应你已经写好的两套方法即可。


内容的提问来源于stack exchange,提问作者Lisa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.12 10:42:02