这似乎是一个很简单的问题。我基本上是在尝试在我创建的界面中创建一个键值对对象。
但是我不知道如何实现它。我一直收到错误 通用类型“Map”需要 2 个类型参数
我的界面对象看起来像这样。我正在尝试将“类型”对象设为键值对。
export interface CalendarEvent<MetaType = any> {
id?: string | number;
start: Date;
end?: Date;
title: string;
color?: EventColor;
actions?: EventAction[];
allDay?: boolean;
cssClass?: string;
resizable?: {
beforeStart?: boolean;
afterEnd?: boolean;
};
draggable?: boolean;
meta?: MetaType;
amount: number;
type: Map<key: string, value: string>
}
最佳答案
只需提供通用类型 - 删除参数名称,即:
Map<string, string>
关于angular - 如何在 Angular 的接口(interface)中实现键值对对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56901799/