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
602 views
in Technique[技术] by (71.8m points)

antd 动态表单,多个select选中项不能重复。

image.png

三个选项,选中后disabled或者直接去掉

通过loadash的xorBy方法已经实现筛选未选中的选项,但每次动态新增一行item,state就会刷新,实现不了。
求求了求求了求求了


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

1 Answer

0 votes
by (71.8m points)

image
这种效果吗?
如果是的话,可以参考这个
disabled={item.code === arrone ? true : false}
把上一个选中的值和第二个选择框值对比,如果相等就disabled

<Select style={{ width: 200 }} value={arrtwo} onChange={(value) =>?this.onChange('arrtwo',value)}>

 {arr.map((item) => (

 <Select.Option key={item.code} value={item.code} label={item.name} disabled={item.code === arrone ? true : false}>

 {item.name}

 </Select.Option>

 ))}

 </Select>

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