【发布时间】:2020-08-25 00:57:57
【问题描述】:
我正在尝试设置从 API 生成的颜色链接的样式。这适用于文本按钮等,但是当我尝试将其应用于链接时它不起作用。
<a href="#" [ngStyle]="{'color': brand?.colours.secondary}" *ngIf="!visitorName" (click)="setVisitor()">Don't want to give your name? That's fine! Start the review!</a>
它只是被引导链接样式覆盖。
将其应用于“p”标签也可以正常工作 - 因此从 API 中提取正确的颜色代码并正常加载:
<p class="mt-5" [ngStyle]="{'color': brand?.colours.secondary}">Don't worry we won't use your details for anything other then to give you the best experience possible.</p>
【问题讨论】:
-
您确定您的打字稿版本是 3.7 或更高版本。从 3.7 开始支持可选链接 (
?.)。