我有一个表格的表包含一排选择。我正在尝试显示各自选择下的选择,但是选择仅在其中一个选择下显示。我不确定这里怎么了。
我在这里有一个工作示例:
在我的代码中,当我更改任何一个选择时,选择在第一个选择下方。谁能解释一下?
I have a table who's header contains a row of selects. I am trying to display the selections under their respective selects however the selections only show under one of the selects. Im not sure whats going wrong here.
I have a working example here: https://codesandbox.io/s/table-with-multiselcts-fwhsus?file=/src/App.js
In my code the selections are updating underneath the first select when I change any one of the selects. Can anyone explain this?
发布评论
评论(1)
您使用了相同的Onchange回调。
问题在于此功能的参数。
字段
不是字符串,它是对象。因此,在Switch语句中,仅执行默认情况。
最好分别设置Onchange回调。
You used the same onChange callback.
The problem is in the parameters of this function.
field
is not a string, it's an object.So in the switch statement, only default case is executed.
It would be better to set onChange callback respectively.