【发布时间】:2020-04-17 15:50:33
【问题描述】:
我正在尝试编写一个要重用的组件,其中一个变量是要呈现的输入类型。
目前,我有这个:
type InputBaseProps = {
children?: ReactChild;
className?: string;
id: string;
label?: string;
name?: string;
onBlur: (event: ChangeEvent<HTMLInputElement>) => void;
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
placeholder?: string;
style?: CSSProperties;
type: ????;
value?: string;
};
我只想允许有效的 HTML types,就像这里定义的整个列表 https://www.w3schools.com/tags/att_input_type.asp
有什么简单的方法吗?
【问题讨论】:
标签: javascript html typescript