Home > Web Front-end > JS Tutorial > body text

How to use React Native datetime selector component

php中世界最好的语言
Release: 2018-06-01 17:30:47
Original
1490 people have browsed it

This time I will show you how to use the React Native date and time selection component. What are the precautions when using the React Native date and time selection component. Here are practical cases, 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
Copy after login

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>
Copy after login

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:

How to make vue-baidu-map to enter the page and automatically locate it

How to use Vue2.0 Call the camera to take pictures

The above is the detailed content of How to use React Native datetime selector component. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template