angular - 忽略部分路由路径
问题描述
我的 Angular 6 应用程序中的一条路线定义如下 -
{ path: 'product/:productId', component: ProductPageComponent }
现在,我想处理这样的 URL /product/BEV15733/Raw-Apple-Cider-Vinegar
(即我想忽略第三个路径段)。但是,在导航时,Angular 会抛出错误,例如 -
错误:无法匹配任何路由。URL 段:'product/BEV15733/Raw-Apple-Cider-Vinegar'
解决方案
也许这会起作用:
{ path: 'product/:productId/:ignoreParam', component: ProductPageComponent }
使用 ':' 你希望你的 url 中有一个参数,你可以忽略这最后一段。
推荐阅读
- java - 如何在 Unity 中使用 android/IOS 设备跟踪人脸?
- c# - 多个数据表到同一工作簿中的多个 Excel 工作表
- python - 在列表中搜索一对整数的算法
- android - 如果 setRetainInstance(true),本地化在片段中不起作用
- c++ - 如何从一个容器中获取某些元素并将这些元素的转换插入另一个容器?
- r - 使用 cor.test 函数的相关性和 p 值
- r - 用R中的数字分割字符串
- python-3.x - 是否可以在 Python 中使用 print 函数打印 1e-3 而不是 0.001?
- c# - 如何在文件更改时使用 Target Copy 复制文件
- vba - 尝试获取单元格 AI 和 BM 的值时出现错误 1004