美文网首页
react-native 关闭软键盘需要点击两次才能触发事件解决

react-native 关闭软键盘需要点击两次才能触发事件解决

作者: 丿一丨丿丶丨一 | 来源:发表于2019-08-12 16:54 被阅读0次

    软键盘消失,焦点依然还在textInput中导致需要点击两次按钮,监听软键盘的消失方法,然后在消失方法里面,再一次调用软键盘消失方法

    const dismissKeyboard = require('dismissKeyboard'); //引入
    
    componentWillMount () {
       this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
       this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
    }
    
    componentWillUnmount() {
       this.keyboardDidShowListener.remove();
       this.keyboardDidHideListener.remove();
    }
    
     _keyboardDidShow () {
    
    }
    _keyboardDidHide () {
       dismissKeyboard();
    }
    

    相关文章

      网友评论

          本文标题:react-native 关闭软键盘需要点击两次才能触发事件解决

          本文链接:https://www.haomeiwen.com/subject/sfnujctx.html