此问题的解决方案是使用Ant-Design的getFieldDecorator方法来绑定表单字段和Switch组件。在getFieldDecorator方法的options对象中,valuePropName属性应设置为“checked”,而不是“value”。
以下是一个示例代码:
{getFieldDecorator('switch', {
valuePropName: 'checked',
initialValue: true, // 可选的
})(
)}