我正在尝试使用以下命令将单选按钮设置为默认选中状态:
import { Field } from "redux-form";
<Field name={radio_name} component={renderField} type="radio" checked={true} value={val1} label="val1"/>
<Field name={radio_name} component={renderField} type="radio" value={val2} label="val2"/>
<Field name={radio_name} component={renderField} type="radio" value={val3} label="val3"/>
const renderField = ({
input,
label,
type
}) =>
(
<div>
<input {...input} type={type}/>
<label>{label}</label>
</div>
);
但是,结果元素中没有checked
属性。有人知道为什么吗?