0

<a routerLink="/Profile">Profile</a>在 index.html 文件中使用时遇到问题。锚标记无法正常工作。我在 index.html 上放置了标题菜单,并希望为 Angular 4 中的路由添加以下代码

<a href="#Profile" routerLink="/Profile" routerLinkActive="active">
<span class="icon-cogs"></span>Profile</a>

<router-outlet></router-outlet>放在 app.component.html中

<a routerLink="/Profile">Profile</a>当我将它放在任何其他组件中但在 index.html 中不起作用时,相同的行代码工作文件

4

1 回答 1

0

你不应该把这段代码放在 index.html 里面,它不会工作,它应该在组件里面。

routerLink 是这样的:

routerLink="/Profile"

所以保持这样:

<a routerLink="/Profile" routerLinkActive="active">

有关更多详细信息,请阅读:

https://angular.io/guide/router

于 2017-11-15T12:15:20.250 回答