Git Product home page Git Product logo

Comments (5)

lyxia avatar lyxia commented on July 18, 2024

https://reactnative.cn/docs/0.51/textinput.html#content
里面有提到:最简单的用法就是丢一个TextInput到应用里,然后订阅它的onChangeText事件来读取用户的输入。注意,从TextInput里取值这就是目前唯一的做法!也就是使用在onChangeText中用setState把用户的输入写入到state中,然后在需要取值的地方从this.state中取出值。

from myrnstartkit.

lyxia avatar lyxia commented on July 18, 2024

源码:
render() {
const { customKeyboardType, ...others } = this.props;
return <TextInput {...others} ref={this.onRef}/>;
}

所以用法同TextInput

from myrnstartkit.

orzhtml avatar orzhtml commented on July 18, 2024

这个明白,缺点是, this.state 重新赋值,会闪烁(删除多余的输入),并且判断会更复杂
例如: 12345.64.99
正常来说,能拦截第二个小数点就方便了
另外还有999999999999.99 用户只能输入的金额不能超过这个位数,包括小数点后两位,如果能拦截按键,那么判断方式也能更简洁。

from myrnstartkit.

lyxia avatar lyxia commented on July 18, 2024

对于官方的TextInput能拦截按键吗?

from myrnstartkit.

orzhtml avatar orzhtml commented on July 18, 2024

rn:臣妾做不到啊

from myrnstartkit.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.