[英]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.