angular - 路线数据中的 Angular 8 路线参数
问题描述
我有以下路线:
{
path: 'introducer/:introducerId/branches/create',
component: IntroducerBranchesCreateComponent,
data: {
pageTitle: 'Add branch',
breadcrumbs: [
{ title: 'Branches', link: '/introducer/' + :introducerId + '/branches' },
{ title: 'Add', link: '' },
],
},
},
在面包屑数组中,我想使用路由参数填充链接属性,:introducerId
但无法这样做。有没有办法做到这一点?
解决方案
我不是 100% 确定这是否可行,但你可以尝试一下
{
path: 'introducer/:introducerId/branches/create',
component: IntroducerBranchesCreateComponent,
data: {
pageTitle: 'Add branch',
breadcrumbs: () => {
const id = this.getIntroducerId();
return [
{ title: 'Branches', link: `/introducer/${id}/branches` },
{ title: 'Add', link: '' },
]
}
},
}
然后将该方法添加getIntroducerId
到您的组件中,并使用data.breadcrumbs
将其作为函数调用而不是仅使用对象属性。
推荐阅读
- c++ - c++ pcl_ros:如何使用最新的 100 条消息生成点云
- math - 给定 w 的 a 和 b 对的数量
- c# - AppInsights 端到端事务详细信息未显示超过 1000 个请求
- macros - 按 ID 和日期填充 SAS 中的字段
- facebook - Facebook 消息:此页面不可用。您关注的链接可能已损坏,或者该页面可能已被删除
- android - android webview中的javascript在galaxy note 8/9中不起作用
- spring - 在自定义注释spring aop中获取返回值
- jboss - jboss server.log 文件仅在服务器启动时更新,日志记录在 start.log 文件中
- php - 设置按钮选择限制
- sql - 需要在 null 的地方重复之前的事务