react-native-yusha-customKeyboard icon indicating copy to clipboard operation
react-native-yusha-customKeyboard copied to clipboard

maxLength属性不起作用

Open mengerzhuanyong opened this issue 6 years ago • 5 comments

如题!~

mengerzhuanyong avatar Jan 23 '19 01:01 mengerzhuanyong

不理解maxLength是来控制什么的。。你是指键盘高度吗?

lyxia avatar Jan 30 '19 02:01 lyxia

不理解maxLength是来控制什么的。。你是指键盘高度吗?

RN里的TextInput不是有个maxLength属性吗,可以限制输入内容的字符串长度

mengerzhuanyong avatar Jan 30 '19 03:01 mengerzhuanyong

同求

qubangliuhui avatar Feb 26 '19 06:02 qubangliuhui

修改customKeyboard.js 里面的_onChangeText @mengerzhuanyong @qubangliuhui

  _onChangeText = text => {
+    const { maxLength } = this.props;
+   if (maxLength && !!text && text.length > maxLength) {
+      return;
+    }
    this.setState({ text });
    this.props.onChangeText && this.props.onChangeText(text);
  };

aloneszjl avatar Mar 18 '19 04:03 aloneszjl

好的,谢谢

发自我的 iPhone

在 2019年3月18日,下午12:01,aloneszjl [email protected] 写道:

修改customKeyboard.js 里面的_onChangeText @mengerzhuanyong @qubangliuhui

_onChangeText = text => {

  • const { maxLength } = this.props;
  • if (maxLength && !!text && text.length > maxLength) {
  •  return;
    
  • } this.setState({ text }); this.props.onChangeText && this.props.onChangeText(text); }; — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

qubangliuhui avatar Mar 18 '19 05:03 qubangliuhui