npm install react-native-datepicker --save
import DatePicker from 'react-native-datepicker';
<View>
<DatePicker
style={{width: 200}}
date={this.state.date}
mode="date"
placeholder="select date"
format="YYYY-MM-DD"
minDate={this.state.date}
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
dateIcon: {
position: 'absolute',
left: 0,
top: 8/1536*width,
marginLeft: 0
},
dateInput: {
marginLeft: 72/1536*width,
borderRadius:10/1536*width
}
// ... You can check the source to find the other keys.
}}
onDateChange={(date) => {
this.setState({date: date});
this.load();
}}
/>
</View> 注意:这里的date类型是string,所以date类型初始化的时候需要tostring,例如moment(new Date()).format(‘YYYY-MM-DD’)

Properties

Prop Default Type Description
style - object Specify the style of the DatePicker, eg. width, height...
date - string | date | Moment instance Specify the display date of DatePicker. string type value must match the specified format
mode 'date' enum The enum of datedatetime and time
androidMode 'default' enum The enum of defaultcalendar and spinner (only Android)
format 'YYYY-MM-DD' string Specify the display format of the date, which using moment.js. The default value change according to the mode.
confirmBtnText '确定' string Specify the text of confirm btn in ios.
cancelBtnText '取消' string Specify the text of cancel btn in ios.
iconSource - {uri: string} | number Specify the icon. Same as the sourceof Image, always using require()
minDate - string | date Restricts the range of possible date values.
maxDate - string | date Restricts the range of possible date values.
duration 300 number Specify the animation duration of datepicker.
customStyles - object The hook of customize datepicker style, same as the native style. dateTouchBodydateInput...
showIcon true boolean Controller whether or not show the icon
hideText false boolean Controller whether or not show the dateText
iconComponent - element Set the custom icon
disabled false boolean Controller whether or not disable the picker
is24Hour - boolean Set the TimePicker is24Hour flag. The default value depend on format. Only work in Android
allowFontScaling true boolean Set to false to disable font scaling for every text component
placeholder '' string The placeholder show when this.props.date is falsy
onDateChange - function This is called when the user confirm the picked date or time in the UI. The first and only argument is a date or time string representing the new date and time formatted by moment.js with the given format property.
onOpenModal - function This is called when the DatePicker Modal open.
onCloseModal - function This is called when the DatePicker Modal close
onPressMask - function This is called when clicking the ios modal mask
modalOnResponderTerminationRequest - function Set the callback for React Native's Gesture Responder System's call to onResponderTerminationRequest. By default this will reject a termination request, but can be overidden in case the View under the Modal is implementing custom gesture responders, and you wish for those to be overidden in certain cases.
TouchableComponent TouchableHighlight Component Replace the TouchableHighlight with a custom Component. For example : TouchableOpacity
getDateStr - Function A function to override how to format the date into a String for display, receives a Date instance

react native 中时间选择插件的更多相关文章

  1. React Native 中 CSS 的使用

    首先声明,此文原作者为黎 跃春 React Native中CSS 内联样式 对象样式 使用Stylesheet.Create 样式拼接 导出样式对象 下面的代码是index.ios.js中的代码: / ...

  2. react native中的欢迎页(解决首加载白屏)

    参照网页: http://blog.csdn.net/fengyuzhengfan/article/details/52712829 首先是在原生中写一些方法,然后通过react native中js去 ...

  3. React Native中的网络请求fetch和简单封装

    React Native中的网络请求fetch使用方法最为简单,但却可以实现大多数的网络请求,需要了解更多的可以访问: https://segmentfault.com/a/1190000003810 ...

  4. [转] 「指尖上的魔法」 - 谈谈 React Native 中的手势

    http://gold.xitu.io/entry/55fa202960b28497519db23f React-Native是一款由Facebook开发并开源的框架,主要卖点是使用JavaScrip ...

  5. [转] 在React Native中使用ART

    http://bbs.reactnative.cn/topic/306/%E5%9C%A8react-native%E4%B8%AD%E4%BD%BF%E7%94%A8art 前半个月捣腾了一下Rea ...

  6. react native中使用echarts

    开发平台:mac pro node版本:v8.11.2 npm版本:6.4.1 react-native版本:0.57.8 native-echarts版本:^0.5.0 目标平台:android端收 ...

  7. react native中一次错误排查 Error:Error: Duplicate resources

    最近一直在使用react native中,遇到了很多的坑,同时也学习到了一些移动端的开发经验. 今天在做一个打包的测试时,遇到了一个问题,打包过程中报错“Error:Error: Duplicate ...

  8. 在React Native中,使用fetch网络请求 实现get 和 post

    //在React Native中,使用fetch实现网络请求 /* fetch 是一个封装程度更高的网络API, 使用了Promise * Promise 是异步编程的一种解决方案 * Promise ...

  9. 《React Native 精解与实战》书籍连载「React Native 中的生命周期」

    此文是我的出版书籍<React Native 精解与实战>连载分享,此书由机械工业出版社出版,书中详解了 React Native 框架底层原理.React Native 组件布局.组件与 ...

随机推荐

  1. MongoDB- 简单操作命令

    MongoDB是基于集合操作的数据库 1.进入与退出 mongo / exit 2.库操作 显示所有库: show dbs; 查看当前所在库: db; 切换&使用某个库: use db_nam ...

  2. idea中Springcloud同时运行多个模块、微服务

    idea中有个窗口叫做 Run DashBoard 在这里可以管理多个模块的启停,这个面板一般情况下是关闭的打开Run DashBoard面板 在工程的.idea中找到workspace.xml,并找 ...

  3. C#行转列&绑定DGV

    c#行转列 今天工作中,恰好写到此处,想起之前第一次行转列的时候,卡壳了好久,今天正好碰上,故而花费几分钟,整理成案例,分享到博客上. 这是个很简单的功能,第一次可以使用案例,后面最好能达到信手拈来的 ...

  4. 数据库升级到mysql5.7出现的1067 - Invalid default value for '字段名' (docker版)

    docker run -d --name xxx mysql:5.7 docker container cp xxx:/etc/mysql/mysql.conf.d .   // 取出mysql中的配 ...

  5. 好程序员web前端分享12个CSS高级技巧汇总

    好程序员web前端分享下面这些CSS高级技巧,一般人我可不告诉他哦. 使用 :not() 在菜单上应用/取消应用边框 给body添加行高 所有一切都垂直居中 逗号分隔的列表 使用负的 nth-chil ...

  6. bzoj2006 [NOI2010]超级钢琴 (及其拓展)

    bzoj2006 [NOI2010]超级钢琴 给定一个序列,求长度在 \([L,\ R]\) 之间的区间和的前 \(k\) 大之和 \(n\leq5\times10^5,\ k\leq2\times1 ...

  7. 第二章 Python基本图形绘制

    2.1 深入理解Python语言 Python语言是通用语言 Python语言是脚本语言 Python语言是开源语言 Python语言是跨平台语言 Python语言是多模型语言 Python的特点与优 ...

  8. vue省市区三级联动

    仿照小米之家做的一个省市区三级联动,先上代码: HTML: <template> <section class="myAddress"> <secti ...

  9. Module build failed: Error: Cannot find module 'babel-runtime/core-js/get-it

    npm i babel-loader@7.1.5 -D

  10. h5手机查看

    1.装个node:2.全局装个anywhere的npm包.(npm i -g anywhere)3.大功告成,现在到任意目录下用命令行执行anywhere就可以:(-p 参数可以设置启动端口) 补充: ...