【发布时间】:2020-02-12 20:10:38
【问题描述】:
无法正常工作,我只想选择一个值,但我可以选择一个和多个......并且无法取消选择
有该功能的代码。
const RadioButtonField = ({type, options, disabled, onChange}) => {
const handleChange = (value) => {
onChange(type, value);
};
return (
<div>
{options.map(({ value, label }) =>
<Radio.Group key={value}>
<Radio
disabled={disabled}
onChange={() => handleChange(value)}
>
{label}
</Radio>
</Radio.Group>
)}
</div>
);
};
【问题讨论】:
-
你在使用
react-radio-group库吗? -
不,我使用 ant design 单选按钮和 redux 表单
-
我的表单域中需要两个选项的单选按钮,是或否
-
您是从其他地方传递
options吗?为什么要传递所有参数? -
我在字段中传递参数
标签: reactjs forms redux radio-button antd