Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
209 views
in Technique[技术] by (71.8m points)

antd中selectedRowKeys的神奇现象?

背景:
点击一个清空勾选按钮,清空已勾选项。

描述:
我自己会出现无法勾选出来的情况,我又捣鼓不出来,于是就在github上去提了issue,然后管理员"偏右"给我解决了。

代码:
我之前的失效代码:codesandbox演示
管理给的有效代码:codesandbox演示

修改处:
他跟我的区别就是rowSelection的写法不同,他把我原项目46行的selectedRowKeys拿出来放在了Table中的rowSelection属性中(他代码的77行)。
我的代码:rowSelection={{ ...this.rowSelection }}
他的代码:

rowSelection={{

...this.rowSelection,

selectedRowKeys: this.state.selectedRowKeys

}}

问题:
为什么我这样的代码会无法勾选,这样的代码问题在哪里?

补充:
github上原issue地址
antd table的api地址


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

你写的这个 rowSelection 没写在 state 里面啊,没触发重新渲染吧


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...