antd switch 没有根据数据更新

原文是根据这里看的https://blog.csdn.net/weixin_43859703/article/details/109826671

看完之后很受启发,因为这个这个之前没有用过,附上我自己写的代码,希望对你们有用

  <Switch defaultChecked={() => {
                        console.log(item.timing_effective)
                        if (item.timing_effective == 1) { return true }
                        if (item.timing_effective == 0) { return false }
                    }}
                    key={item.timing_effective}
                        onChange={() => {
                            if (item.timing_effective == 1) {
                                sdk.controlDeviceData({ "num_down": item.num_down, "timing_effective": 0 })
                                sdk.controlDeviceData({ "get_timed_task": 1 })
                            } else {
                                sdk.controlDeviceData({ "num_down": item.num_down, "timing_effective": 1, "power_switch": item.power_switch, "time_down": item.time_down, "week_down": item.week_down })
                                sdk.controlDeviceData({ "get_timed_task": 1 })
                            }
                        }}></Switch>

 

上一篇:antd a-select 获取选中得label


下一篇:秒懂数据类型的真谛—Python基础前传(4)