我只是试图从语义ui react下拉组件中获取选定的值。单击按钮后,我想获取任何选定的值,然后在React Apollo查询中将变量的状态设置为那些选定的值。
---Component---
<Dropdown className="dropdowns" placeholder='Select One or More' search multiple fluid clearable selection options={pms} id={'Search'}/>
---Get logic that was working with a non-semantic-ui selector---
let Obj = document.getElementById('Search').options
var programManagers = []
for(var i = 0; i < Obj.length; i++) {
var opt = Obj[i]
if(opt.selected) {
array.push(opt.value)
}
}
然后,我可以在React Apollo查询中使用该数组。
您可以将所选项目保存到应用程序状态,shown here这没有取消选择项的逻辑,但是它说明了一般的想法。