1.安装
yarn add react-native-keyboard-aware-scroll-view
2.引入
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
3.调用
4.常用方法
(1)跳到自定输入框
_scrollToInput (reactNode: any) { // Add a 'scroll' ref to your ScrollView this.scroll.scrollToFocusedInput(reactNode)}{this.scroll = ref}}> { // `bind` the function if you're using ES6 classes this._scrollToInput(ReactNative.findNodeHandle(event.target)) }} />
(2)监听 键盘显示或隐藏 onKeyboardWillShow
和 onKeyboardWillHide
:
{ console.log('Keyboard event', frames) }}>
5.效果图