代码之家  ›  专栏  ›  技术社区  ›  danday74

如何设计routerLink的角度

  •  -1
  • danday74  · 技术社区  · 6 年前

    我的应用程序中有很多表行。有些是链接,有些不是。下面是一个例子:

    <tr [routerLink]="['/invoices', invoice?.invoice.id || 0, 'sms']">
    

    我想用这样的routerLink设计所有tr:

    tr[routerLink] {
       cursor: pointer;
    }
    

    但它不起作用。这里正确的CSS是什么?谢谢

    3 回复  |  直到 6 年前
        1
  •  3
  •   user4676340 user4676340    6 年前

    使用编译后的属性 ng-reflect-router-link stackblitz

    a[ng-reflect-router-link] {
      color: red;
      font-weight: 700;
    }
    
    tr[ng-reflect-router-link] {
      cursor: pointer;
    }
    
        2
  •  0
  •   Ayoub k    6 年前

    html格式:

    <a [routerLink]='link' [ngClass]="{'router-link-active': true">{{name}}</a>
    

    .router-link-active {
       cursor: pointer;
    }
    
        3
  •  0
  •   Aniket Avhad    6 年前

    你的问题是因为 这些括号

    这是一个例子

    <tr [routerLink]="['/invoices', invoice?.invoice.id || 0, 'sms']" routerLinkActive="active>
    

    style.css

    tr[routerLinkActive] {
        color: red;
     }
    

    这是 Stackblitz 演示

    这种样式只适用于那些链接