React Native提供自動完成的下拉菜單的方法示例
正文
一個具有搜索和自動完成(typeahead)功能的React Native的下拉項目選擇器。
如何使用它
1.安裝
# Yarn $ yarn add react-native-autocomplete-dropdown # NPM $ npm i react-native-autocomplete-dropdown
2.導(dǎo)入自動完成的下拉組件
import { AutocompleteDropdown } from 'react-native-autocomplete-dropdown';
3.基本使用方法
const [selectedItem, setSelectedItem] = useState(null); <AutocompleteDropdown clearOnFocus={false} closeOnBlur={true} closeOnSubmit={false} initialValue={{ id: '2' }} // or just '2' onSelectItem={setSelectedItem} dataSet={[ { id: '1', title: 'Alpha' }, { id: '2', title: 'Beta' }, { id: '3', title: 'Gamma' }, ]} />;
4.數(shù)據(jù)集應(yīng)該是一個JS對象或數(shù)組
如下所示
[ { id: "1", title: "Alpha" }, { id: "2", title: "Beta" }, { id: "3", title: "Gamma" } ]
5.可用的道具
dataSet?: TAutocompleteDropdownItem[]; inputHeight?: number; suggestionsListMaxHeight?: number; initialValue?: string | object; loading?: boolean; useFilter?: boolean; showClear?: boolean; showChevron?: boolean; closeOnBlur?: boolean; closeOnSubmit?: boolean; clearOnFocus?: boolean; debounce?: number; direction?: 'down' | 'up'; position?: 'absolute' | 'relative'; bottomOffset?: number; textInputProps?: TextInputProps; onChangeText?: (text: string) => void; onSelectItem?: (item: TAutocompleteDropdownItem) => void; renderItem?: ( item: TAutocompleteDropdownItem, searchText: string, ) => JSX.Element; onOpenSuggestionsList?: (isOpened: boolean) => void; onClear?: () => void; onChevronPress?: () => void; onSubmit?: TextInputProps['onSubmitEditing']; onBlur?: TextInputProps['onBlur']; onFocus?: TextInputProps['onFocus']; controller?: (controller: AutocompleteDropdownRef) => void; containerStyle?: StyleProp<ViewStyle>; inputContainerStyle?: StyleProp<ViewStyle>; rightButtonsContainerStyle?: StyleProp<ViewStyle>; suggestionsListContainerStyle?: StyleProp<ViewStyle>; suggestionsListTextStyle?: StyleProp<TextStyle>; ChevronIconComponent?: JSX.Element; ClearIconComponent?: JSX.Element; InputComponent?: React.ComponentType; ItemSeparatorComponent?: JSX.Element; EmptyResultComponent?: JSX.Element; emptyResultText?: string; flatListProps?: FlatListProps<any>
預(yù)覽
The postAutocomplete Dropdown For React Nativeappeared first onReactScript.
以上就是React Native提供自動完成的下拉菜單的方法示例的詳細(xì)內(nèi)容,更多關(guān)于React Native自動完成下拉菜單的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
React Antd中如何設(shè)置表單只輸入數(shù)字
這篇文章主要介紹了React Antd中如何設(shè)置表單只輸入數(shù)字問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-06-06React Native預(yù)設(shè)占位placeholder的使用
本篇文章主要介紹了React Native預(yù)設(shè)占位placeholder的使用,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-09-09React系列useSyncExternalStore學(xué)習(xí)詳解
這篇文章主要為大家介紹了React系列useSyncExternalStore的學(xué)習(xí)及示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07react-native 封裝選擇彈出框示例(試用ios&android)
本篇文章主要介紹了react-native 封裝選擇彈出框示例(試用ios&android),具有一定的參考價值,有興趣的可以了解一下2017-07-07React、Vue中key的作用詳解 (key的內(nèi)部原理解析)
key是虛擬DOM對象的標(biāo)識,當(dāng)狀態(tài)中的數(shù)據(jù)發(fā)生變化時,Vue會根據(jù)[新數(shù)據(jù)]生成[新的虛擬DOM],本文給大家介紹React、Vue中key的作用詳解 (key的內(nèi)部原理解析),感興趣的朋友一起看看吧2023-10-10React引入css的幾種方式及應(yīng)用小結(jié)
這篇文章主要介紹了React引入css的幾種方式及應(yīng)用小結(jié),操作styled組件的樣式屬性,可在組件標(biāo)簽上定義屬性、也可以通過attrs定義屬性,本文通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-03-03