日期文本输入 React Native 的自动反斜杠? [英] Automatic backslash for Date Text Input React Native?

查看:43
本文介绍了日期文本输入 React Native 的自动反斜杠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何创建一个文本输入,当您开始输入时,它会自动允许一定数量的数字,并为数字自动反斜杠分隔.

Does anyone know how to create a text input that when you start typing in it, it automatically allows for a certain amount of digits with an automatic backslash separation for the numbers.

DD/MM/YYYY(我不打算使用日期选择器或库).

DD / MM / YYYY (I am not looking to use a date picker or library).

推荐答案

试试这个 react 组件:

Try this react component:

https://github.com/benhurott/react-native-masked-text

npm install react-native-masked-text --save

render() {
//the type is required but options is required only for some specific types.
  return (
    <TextInputMask
      refInput={(ref) => this.myDateText = ref;}
      type={'datetime'}
      options={{
        format: 'DD-MM-YYYY HH:mm:ss'
      }}
    />
  )
}

有一种面膜适合您:

日期时间:使用具有时刻格式的日期时间掩码(默认为 DD/MM/YYYY HH:mm:ss).它接受选项(见本文档后面部分).

datetime: use datetime mask with moment format (default DD/MM/YYYY HH:mm:ss). It accepts options (see later in this doc).

这篇关于日期文本输入 React Native 的自动反斜杠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆