【问题标题】:placing routerLInk on a tag but a tag not clickable angular 6将 routerLInk 放在标签上,但标签不可点击 angular 6
【发布时间】:2018-10-27 04:35:12
【问题描述】:

我有一堆链接

html

<div class="col-12 navlinks">
        <div class="text-center">
          <div class="justify-content-center">
            <a class="col-auto d-inline-block whitelink" routerLink="/team">The Team</a>
            <a class="col-auto d-inline-block whitelink" routerLink="/privacy">Privacy</a>
            <a class="col-auto d-inline-block whitelink" routerLink="/terms">Terms</a>
            <a class="col-auto d-inline-block whitelink" routerLink="/contact">Contact Us</a>
          </div>
        </div>
      </div>

css

.navlinks{
  margin-bottom: 10px;
}
.whitelink{
  color: white;
  cursor: pointer;
}

现在光标没有变成指针 点击链接什么也不做。

正确实现这些链接工作的路线和所有其他要求。只是出于某种原因,这些链接认为它们很特别。我猜他们的父母把他们宠坏了。不确定,不管怎样,我都在努力让他们回到正轨,否则我会把他们送到海军陆战队的新兵训练营去塑造他们......

为什么要这样做?

【问题讨论】:

  • 你能提供你的 app.module.ts 吗?看起来像const routes: Routes = [ { path: 'team', component: YourTeamComponent }, { path: 'privacy', component: YourPrivacyComponent }, ]; 吗?
  • @Maarti 是的,是的,是的,是的,是的,是的!
  • 你是否导入了路由模块并将路由数组传递给模块的 for Root 方法它看起来像这样@NgModule({ imports: [RouterModule.forRoot(routes)], })

标签: html angular anchor


【解决方案1】:

我可以看到光标与您的代码完全相同!如果您有白色背景,请尝试将 whitelink 类的颜色属性更改为黑色!

.whitelink{
  color: black;
  cursor: pointer;
}

另外,请确保您已为 routerlink 路径定义了路由!

【讨论】:

  • 很不幸,这根本不是解决方案。似乎该网站将其视为 p 标签而不是 a 标签,不知道为什么。
猜你喜欢
  • 2019-06-26
  • 2023-02-26
  • 2016-08-16
  • 2015-04-02
  • 1970-01-01
  • 1970-01-01
  • 2020-03-20
  • 2021-03-27
  • 2016-10-09
相关资源
最近更新 更多