Home  >  Article  >  Web Front-end  >  Detailed explanation of React Native date and time selection component examples

Detailed explanation of React Native date and time selection component examples

php中世界最好的语言
php中世界最好的语言Original
2018-05-15 10:41:082442browse

This time I will bring you a detailed explanation of the React Native date and time selection component example. What are the precautions when using the React Native date and time selection component. The following is a practical case, let's take a look.

React Native date and time selection component: react-native-datepicker, supports Android and IOS dual platforms, supports independent selection of dates, independent selection of time and selection of date and time, and supports custom date formats.

Rendering

##InstallationMethod

npm install react-native-datepicker --save

Sample code

<Text style={styles.instructions}>time: {this.state.time}</Text>
    <DatePicker
     style={{width: 200}}
     date={this.state.datetime}
     mode="datetime"
     format="YYYY-MM-DD HH:mm"
     confirmBtnText="确定"
     cancelBtnText="取消"
     showIcon={false}
     onDateChange={(datetime) => {this.setState({datetime: datetime});}}
    />
    <Text style={styles.instructions}>datetime: {this.state.datetime}</Text>
    <DatePicker
     style={{width: 200}}
     date={this.state.datetime1}
     mode="datetime"
     format="YYYY-MM-DD HH:mm"
     confirmBtnText="确定"
     cancelBtnText="取消"
     customStyles={{
      dateIcon: {
       position: &#39;absolute&#39;,
       left: 0,
       top: 4,
       marginLeft: 0
      },
      dateInput: {
       marginLeft: 36
      }
     }}
     minuteInterval={10}
     onDateChange={(datetime) => {this.setState({datetime1: datetime});}}
    />
    <Text style={styles.instructions}>datetime: {this.state.datetime1}</Text>

Main parameter description

date: Set the initial displayed date mode: Display mode, date, datetime, time format: Set the date format, the default is 'YYYY-MM-DD' confirmBtnText: the display name of the confirm button cancelBtnText: the display name of the cancel button minDate: the minimum date displayed maxDate: the maximum date displayed duration: time interval onDateChange: triggered when the date changes

Event placeholder: Placeholder

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Vue implementation of PopupWindow component usage steps analysis

vue jquery lodash top suspension fixed function implementation when sliding Detailed explanation

The above is the detailed content of Detailed explanation of React Native date and time selection component examples. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn