Skip to content

Instantly share code, notes, and snippets.

@chuyihuang
Created September 26, 2017 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuyihuang/da7badeab22f4fe580734d47d59534a9 to your computer and use it in GitHub Desktop.
Save chuyihuang/da7badeab22f4fe580734d47d59534a9 to your computer and use it in GitHub Desktop.
week_7_demo7
import React, { Component } from 'react'
import { View, Text } from 'react-native';
import DatePicker from 'react-native-datepicker'
export default class DatePickerExample extends Component {
constructor(props){
super(props)
this.state = {date:"2016-05-15"}
}
render(){
return (
<View style={{marginTop: 100, alignItems: 'center'}}>
<DatePicker
style={{width: 200}}
date={this.state.date}
mode="date"
placeholder="select date"
format="YYYY-MM-DD"
maxDate="2017-10-01"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
dateIcon: {
position: 'absolute',
left: 0,
top: 4,
marginLeft: 0
},
dateInput: {
marginLeft: 36
}
}}
onDateChange={(date) => {this.setState({date: date})}}
/>
<Text>選擇日期{this.state.date}</Text>
</View>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment