H5内,单选框,首先想到html标签select,如下代码
const renderSelect = (options) => (
<select>
{(options || []).map((item) => (
<option key={item.value} value={item.value}>{item.title}</option>
))}
</select>
);
存在兼容性问题(真机上的样式不美观),不能使用select实现
替代方案是使用antd-mobile的Picker实现,代码如下
renderList = (props) => {
const { options, form } = props;
return (
<List>
<Picker
extra="请选择"
data={options}
{...form.getFieldProps('department', { initialValue: '1' })}
>
<List.Item arrow="horizontal">部门</List.Item>
</Picker>
</List>
);
};
antd-mobile Picker 文档链接为:Ant Design Mobile | A Mobile Design Specification