点击键盘的return键直接切换到下一个文本框(键盘不收回)

今天,碰到一个需求:登录界面,输入账号之后点击键盘的确定/next按钮切换到密码输入框
代码如下:

const dismissKeyboard = require('dismissKeyboard');

  dismissKeyboardClick = () => {
    dismissKeyboard();
  }

  focusNext = (nextField) => {
    this.refs[nextField].focus();
  }

  render() {
    return (
       this.dismissKeyboardClick()}>
        
          
            
              
              {this.state.loginTitle}
            
          
          
            
              账号:
               this.focusNext('password')}
                onChangeText={(text) => {
                  this.setState({
                    username: text
                  });
                }}
                value={this.state.username}
              />
            
            
              密码:
               this.clickLoginBtn()}
                onChangeText={(text) => {
                  this.setState({
                    password: text
                  });
                }}
                value={this.state.password}
              />
            
          
          
             this.clickLoginBtn()}
            >
              登 录
            
          
          
             this.changeRole(0)}
            >
              医疗端
            
             this.changeRole(1)}
            >
              客服端
            
          
        
      
    );
  }

你可能感兴趣的:(点击键盘的return键直接切换到下一个文本框(键盘不收回))