是否可以在 JavaScript 中创建枚举值并将它们分配给整数值,类似于其他语言。例如,在 C# 中,我通过以下方式声明枚举:
enum WeekDays
{
Monday = 0,
Tuesday =1,
Wednesday = 2,
Thursday = 3,
Friday = 4,
Saturday =5,
Sunday = 6
}
Run Code Online (Sandbox Code Playgroud) 我试图从头开始制作一张有角度的桌子。我希望我的标题和正文是动态的。
<my-datatable>
<my-header header></my-header>
<my-body body></my-body>
</my-datatable>
Run Code Online (Sandbox Code Playgroud)
我的标题组件是
<thead >
<tr>
<th style="text-align: left;" *ngFor="let field of fields | async ">
{{ field }}
</th>
</tr>
</thead>
Run Code Online (Sandbox Code Playgroud)
我的身体成分是
<tbody>
<tr *ngFor="let item of items | async ; let rowIndex = index; " >
<td *ngFor="let field of fields | async; let colIndex = index;" >
{{ item[field] }}
</td>
</tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)
我的数据表组件
<table>
<ng-content select="[header]"></ng-content>
<ng-content select="[body]"></ng-content>
</table>
Run Code Online (Sandbox Code Playgroud)
该表已显示,但显示为两张表,即使我检查时只显示一张表。