【发布时间】:2019-10-01 15:36:06
【问题描述】:
我有一个 Angular 项目,我想在其中链接到其他页面上的书签。所以在我的html中我有这样的链接:
<a href="#products" routerLink="overview">products</a>
但是当页面编译并运行时,我看到这个链接被重写为:
<a _ngcontent-kfm-c5="" href="/overview/overview" routerlink="overview" ng-reflect-router-link="overview">products</a>
链接不起作用的明显效果。
在 app-router.module.ts 中,路由定义为
{ path: 'main', component: MainComponent },
{ path: 'overview', component: OverviewComponent },
{ path: '', redirectTo: '/main', pathMatch: 'full' },
{ path: '**', component: MainComponent }
以前可以正常工作。
这是预期的行为吗?我错过了什么吗?我有一些使用类似链接的旧项目,它们可以正常工作。或者这是一个角度路由器错误?我的角度核心是 7.2.0,我的角度路由器是 7.2.15。 任何指针都非常感谢,因为我一直在调试这个。
【问题讨论】:
-
为什么要同时使用routerlink和href?
标签: angular angular-ui-router href routerlink