<Form.Item label="推送" name="top">
<Switch defaultChecked checkedChildren={<CheckOutlined />} unCheckedChildren={<CloseOutlined />} />
</Form.Item>
点击提交按钮提交开关的表单值top为undefined
解决方法:
需添加valuePropName="checked",并设置默认值 initialValue
<Form.Item label="推送" name="top" valuePropName="checked" initialValue={true} >
<Switch defaultChecked checkedChildren={<CheckOutlined />} unCheckedChildren={<CloseOutlined />} />
</Form.Item>
p.s:
如果设置initialValue无效,则为form设置默认值