无名商城论坛

搜索
查看: 214|回复: 0

[其他技术] 【LSP】Angular应用的路由指令RouterLink

[复制链接]

1万

主题

1万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
32464
发表于 2022-5-8 17:02:48 | 显示全部楼层 |阅读模式


Angular应用的路由指令RouterLinkapp Component html源代码:

<h1>{{title}}</h1>
<nav>
    <a routerLink="/heroes">Heroes</a>
  </nav>
<router-outlet></router-outlet>
<app-messages></app-messages>
A routerLink attribute is set to "/heroes", the string that the router matches to the route to HeroesComponent. The routerLink is the selector for the RouterLink directive that turns user clicks into router navigations. It's another of the public directives in the RouterModule.

HTML原声标签a的属性routerlLink,是RouterLink指令的选择器,将用户点击转换成navigation. RouterLink是RouterModule里的公有指令。

运行时效果:点击了超链接后,会跳转到localhost:4200/heroes:



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表