![](/img/trans.png)
[英]Semantic UI React Dropdown Search - Access autocomplete suggestion on close or enter
[英]react semantic dropdown not working on Enter key
當我輸入值並輸入時,我在輸入中獲取了值,但代碼沒有生成值。
<label>Country</label>
<Dropdown
placeholder={`${enteredCountry}`}
search selection
options={countryOptions}
defaultValue={enteredCountry}
onChange =
{searchHandler
}
/>
我得到了這樣的修復...
const searchHandler = (e,data) =>{
setEnteredCountry(e.target.textContent);
console.log('text value ',e.target.textContent)
if(e.code === 'Enter'){
console.log('data.....',data);
data.options.forEach(element => {
element.value === data.value && setEnteredCountry(element.text)
});
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.