angular router文档包含以下有关如何使事件路由器链接准确的代码片段:
The RouterLinkActive directive toggles css classes for active RouterLinks based on the current RouterState. This cascades down through each level of the route tree, so parent and child router links can be active at the same time. To override this behavior, you can bind to the [routerLinkActiveOptions] input binding with the { exact: true } expression. By using { exact: true }, a given RouterLink will only be active if its URL is an exact match to the current URL.
有人有精确路由器链接的演示吗?
最佳答案
在下面的示例中,active-link
类将
仅当 URL 为 /inbox
时才添加,而不是 /inbox/33
。
<a [routerLink]="/inbox"
routerLinkActive="active-link"
[routerLinkActiveOptions]="{exact: true}">
Inbox
</a>
关于javascript - 事件精确路由器链接演示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44526521/