如何从语义ui反应将参数传递给Dropdown组件?

问题描述 投票:0回答:1

我在下面有我的React js代码,我在其中将语义ui react Dropdown组件放在了map中。 yoe是处于状态的数组,我放置了value={yoe[i]},但是如何将索引i传递给onChange道具?我尝试了以下操作,但是方法onAddYoe似乎无法识别i。有人可以帮忙吗?谢谢!

              {specialties &&
                specialties.map((specialty, i) => {
                  return (
                    <div className="a-row" key={i}>
                      <div className="a-col-md-12">
                        <div className="a-text-box">
                          <label className="a-mb-5">
                            Years of experience in {specialty}
                          </label>
                          <br />
                          <Dropdown
                            placeholder="0-1 years"
                            fluid
                            selection
                            value={yoe[i]}
                            options={this.yoeList}
                            onChange={this.onAddYoe(i)}
                          />
                          {errors.email ? (
                            <span className="error">Email Required</span>
                          ) : null}
                        </div>
                      </div>
                    </div>
                  );
                })}
reactjs semantic-ui-react
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.