[英]get name of select component in antd
我无法在 antd 中获取 select 组件的名称以在 onchange 中使用 handleInputChange function 所以我尝试在 onchange 中设置 setState 并添加到 ZA8CFDE6331BD59EB2AC96F8911C4B6666
const handleInputChange = (e) => {
const name = e.target.name;
const value = e.target.value;
setNewCommodityAndService({ ...newCommodityAndService, [name]: value });
}
};
<Form.Item label="service">
<Select
onChange={handleInputChange}
fieldNames="goods_group_id"
placeholder="select"
id="test"
>
{allCommodityAndServicesGroup?.map((commodityAndService) => {
return (
<Option value={commodityAndService.id}>{commodityAndService.name}</Option>
)
})
}
</Select>
</Form.Item>
您错误地设置了 onChange 道具。 你在道具中调用它,而不是你只需要设置道具。
<Select
onChange={handleInputChange}
fieldNames="goods_group_id"
placeholder="select"
id="test"
>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.