今天我们来说下RN对键盘事件的支持。
在react-native 的Component组件中有个Keyboard.
github地址如下: https://github.com/facebook/react-native/tree/770091f3c13f7c1bd77c50f979d89a774001fbf0/Libraries/Components/Keyboard我们先来看下官方提供的例子,监听键盘的弹出与消失。Demo如下:
import React, { Component } from 'react';
import { Keyboard, TextInput } from 'react-native';
class Example extends Component {
componentWillMount () {
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
this.keyboardDidHideListener = Keyboar