我希望能夠按下搜索欄的搜索欄圖示,并讓它的行為方式與按下搜索欄的占位符相同。因此,當我按下圖示時,它必須顯示我的鍵盤等......我試圖搜索如何做到這一點,但我沒有得到任何結果。這是我當前的代碼:
<View style={{zIndex: 99}}>
<Searchbar
style={{borderRadius: 100, height: 35, backgroundColor: '#FAFAFA', elevation: 0, width: 0, top: 185, left: 180}}
placeholder='Search post '
placeholderTextColor='#E0E0E0'
iconColor="grey"
fontSize={5}
/>
</View>
uj5u.com熱心網友回復:
您可以使用useRef來實作這一點。檔案
例如:
const ref = React.useRef(null);
return (
<View style={{marginTop:100}}>
<Searchbar
placeholder="Search post"
placeholderTextColor='#E0E0E0'
onChangeText={onChangeSearch}
value={searchQuery}
iconColor="grey"
onIconPress={()=>ref.current.focus()}
ref={ref}
/>
去世博試試
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/521100.html
標籤:反应式
上一篇:Java中的SQL選擇在單元測驗中沒有從H2資料庫回傳任何結果
下一篇:驗證輸入的值是否已經存在于陣列中
