【发布时间】:2021-02-07 16:16:53
【问题描述】:
如果我尝试在 NativeScript 视图中呈现硬编码的 FontAwesome 图标,如下所示:
<Label class="fas" text=""></Label>
...然后正确显示。但是,如果我尝试通过使用 text="{{ item.faIcon }}" 或 [text]="item.faIcon" 来呈现动态生成的 FontAwesome 图标,如下所示:
private buildMenuItems() {
this.menuItems = [];
this.menuItems.push({ title: 'Alerts', faIcon: '', url: '/alerts/list' });
this.menuItems.push({ title: 'Properties', faIcon: '', url: '/properties/list' });
this.menuItems.push({ title: 'Tenants', faIcon: '', url: '/tenants/list' });
this.menuItems.push({ title: 'Accounting', faIcon: '', url: '/accounting/transactions/list' });
this.menuItems.push({ title: 'Task Management', faIcon: '', url: '/todos/list' });
this.menuItems.push({ title: 'Documents', faIcon: '', url: '/documents/list' });
this.menuItems.push({ title: 'Reports', faIcon: '', url: '/reports/list' });
this.menuItems.push({ title: 'Notes', faIcon: '', url: '/notes/list' });
}
<WrapLayout orientation="horizontal" itemWidth="120" class="menu">
<StackLayout orientation="vertical" *ngFor="let item of menuItems" (tap)="selectMenuItem(item)">
<Label class="fas" text="{{ item.faIcon }}"></Label>
<Label class="fas" [text]="item.faIcon"></Label>
<Label class="title" [text]="item.title"></Label>
</StackLayout>
</WrapLayout>
...然后它将 faIcon 字符显示为文本而不是实际图标。如何显示实际的图标?
【问题讨论】:
标签: angular nativescript font-awesome nativescript-angular