我在使用 Angular 8 进行样式清理时遇到问题。我多次使用 ngStyle,但这次我无法设置元素的边框td。
我正在尝试根据字段设置边框样式。如果该字段有与我相关的内容,那么我会突出显示它,否则我不会突出显示。我不知道该字段可能值的数量,也不知道确切的值:它完全是动态的,我只知道我感兴趣的值。
我从.ts文件内的函数返回边框样式。以下是代码片段:
<ng-container matColumnDef="{{cam}}">
<th mat-header-cell *matHeaderCellDef class="header"> {{cam}} </th>
<td mat-cell *matCellDef="let piano" class="cellaMagazzino" [ngStyle]=" {'border':shouldHighlight(piano[cam])}">
<div>
<!--content-->
</div>
</td>
</ng-container>
Run Code Online (Sandbox Code Playgroud)
我的打字稿函数如下所示:
shouldHighlight(element){
if (this.listaCommittenti == undefined && this.listaNumOrdine == undefined) {
let found = this.releventContentList.find(item => item.property == element.property)
let result = found != undefined ? '3px solid ' + this.myVariable["color"] : ""
return result
}
Run Code Online (Sandbox Code Playgroud)
我其他时候使用 ngStyle 调用函数,但在这种情况下我收到错误:
警告:清理不安全样式值 3px 实心 rgb(241, 196, 15)(请参阅http://g.co/ng/security#xss)。
是否需要进行某种配置?有解决方法吗?
我正在开发一个网络应用程序,我想将桌面和移动设备的用户界面分开,所以我想检查使用我的应用程序的客户端是否是移动设备。
我尝试在网上查找官方文档或 vaadin 论坛,但我找不到任何有用的信息,因为这些答案中提出的几乎所有解决方案都不再可实现(这些方法已被删除)。