textinput有哪个属性可以控制输入的只能是数字或者英文的吗
-
textinput有哪个属性可以控制输入的只能是数字或者英文的吗
-
原文档:https://facebook.github.io/react-native/docs/textinput.html#keyboardtype
这边的翻译:http://reactnative.cn/docs/0.46/textinput.html#keyboardtype (看起来有点滞后)答案是 keyboardType,目前支持:
- default
- numeric
- email-address
- phone-pad
-
@7c00 说:
原文档:https://facebook.github.io/react-native/docs/textinput.html#keyboardtype
这边的翻译:http://reactnative.cn/docs/0.46/textinput.html#keyboardtype (看起来有点滞后)答案是 keyboardType,目前支持:
- default
- numeric
- email-address
- phone-pad
numeric还是会有空格小数点之类的按钮在,还是会有问题。
用onChangeText删除非数字的话会有明显的删除动作,不知道有没有直接禁止输入的办法
-
最完美的方案只有自己画一个键盘了
-
@7c00 说:
原文档:https://facebook.github.io/react-native/docs/textinput.html#keyboardtype
这边的翻译:http://reactnative.cn/docs/0.46/textinput.html#keyboardtype (看起来有点滞后)答案是 keyboardType,目前支持:
- default
- numeric
- email-address
- phone-pad
-
要用正则表达式做判断,键盘属性限制的只是键盘按钮,无法控制输入内容