Comments (5)
https://reactnative.cn/docs/0.51/textinput.html#content
里面有提到:最简单的用法就是丢一个TextInput到应用里,然后订阅它的onChangeText事件来读取用户的输入。注意,从TextInput里取值这就是目前唯一的做法!也就是使用在onChangeText中用setState把用户的输入写入到state中,然后在需要取值的地方从this.state中取出值。
from myrnstartkit.
源码:
render() {
const { customKeyboardType, ...others } = this.props;
return <TextInput {...others} ref={this.onRef}/>;
}
所以用法同TextInput
from myrnstartkit.
这个明白,缺点是, this.state 重新赋值,会闪烁(删除多余的输入),并且判断会更复杂
例如: 12345.64.99
正常来说,能拦截第二个小数点就方便了
另外还有999999999999.99 用户只能输入的金额不能超过这个位数,包括小数点后两位,如果能拦截按键,那么判断方式也能更简洁。
from myrnstartkit.
对于官方的TextInput能拦截按键吗?
from myrnstartkit.
rn:臣妾做不到啊
from myrnstartkit.
Related Issues (5)
- IOS 加起来 启动xcode 报错 HOT 1
- 求指教,自定义键盘可以剥离出来关键文件么? HOT 2
- No bundle URL present. HOT 4
- 脚手架的2个小问题 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from myrnstartkit.