我尝试使用枚举值作为数组的索引,但它给了我一个错误。
export class Color {
static RED = 0;
static BLUE = 1;
static GREEN = 2;
}
let x = ['warning', 'info', 'success'];
let anotherVariable = x[Color.RED]; <---- Error: Type 'Color' cannot be used as an index type.
Run Code Online (Sandbox Code Playgroud)
我尝试了Number()和parseInt转换为数字,但是它不起作用。
有什么方法可以将Enum值用作索引?
我想让用户在 mat-chip 中仅输入一个芯片并自动完成。我知道 md-chips 有 md-max-chips 来设置最大芯片数。但我正在使用 mat-chip,如何设置这样的最大芯片数量?
<mat-chip-list maxLength="1">
:
:
</mat-chip-list>
Run Code Online (Sandbox Code Playgroud)