我有以下枚举
export enum Sizes{
Small,
Large
}
这是在我的<Demo/>
组件的道具界面中使用的:
export interface IProps{
Label?: string;
Size: SizeEnum;
}
我的问题是,当我使用这个<Demo Size={how do i define size here?} />
?
您可以像在任何其他上下文中一样引用枚举值:
export enum Sizes{
Small,
Large
}
export interface IProps{
Label?: string;
Size: Sizes;
}
class Demo extends React.Component<IProps> {}
let d = <Demo Size={Sizes.Large} />