react native 中时间选择插件
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 date, datetime and time |
| androidMode | 'default' | enum |
The enum of default, calendar 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. dateTouchBody, dateInput... |
| 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 中时间选择插件的更多相关文章
- React Native 中 CSS 的使用
首先声明,此文原作者为黎 跃春 React Native中CSS 内联样式 对象样式 使用Stylesheet.Create 样式拼接 导出样式对象 下面的代码是index.ios.js中的代码: / ...
- react native中的欢迎页(解决首加载白屏)
参照网页: http://blog.csdn.net/fengyuzhengfan/article/details/52712829 首先是在原生中写一些方法,然后通过react native中js去 ...
- React Native中的网络请求fetch和简单封装
React Native中的网络请求fetch使用方法最为简单,但却可以实现大多数的网络请求,需要了解更多的可以访问: https://segmentfault.com/a/1190000003810 ...
- [转] 「指尖上的魔法」 - 谈谈 React Native 中的手势
http://gold.xitu.io/entry/55fa202960b28497519db23f React-Native是一款由Facebook开发并开源的框架,主要卖点是使用JavaScrip ...
- [转] 在React Native中使用ART
http://bbs.reactnative.cn/topic/306/%E5%9C%A8react-native%E4%B8%AD%E4%BD%BF%E7%94%A8art 前半个月捣腾了一下Rea ...
- react native中使用echarts
开发平台:mac pro node版本:v8.11.2 npm版本:6.4.1 react-native版本:0.57.8 native-echarts版本:^0.5.0 目标平台:android端收 ...
- react native中一次错误排查 Error:Error: Duplicate resources
最近一直在使用react native中,遇到了很多的坑,同时也学习到了一些移动端的开发经验. 今天在做一个打包的测试时,遇到了一个问题,打包过程中报错“Error:Error: Duplicate ...
- 在React Native中,使用fetch网络请求 实现get 和 post
//在React Native中,使用fetch实现网络请求 /* fetch 是一个封装程度更高的网络API, 使用了Promise * Promise 是异步编程的一种解决方案 * Promise ...
- 《React Native 精解与实战》书籍连载「React Native 中的生命周期」
此文是我的出版书籍<React Native 精解与实战>连载分享,此书由机械工业出版社出版,书中详解了 React Native 框架底层原理.React Native 组件布局.组件与 ...
随机推荐
- js获取数组中最大值,最小值
遍历方法 var arr =[12,14,34,566,34,98,77] var max = arr[0]; for(var i=0;i<arr.length;i++){ if(max< ...
- [LeetCode] 18. 四数之和
题目链接:https://leetcode-cn.com/problems/4sum/ 题目描述: 给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个 ...
- Elastic Stack-Kibana使用介绍(七)
一.前言 主要来讲述一下Kibana使用以及上生产时候的一些配置,要是大家对这块比较感兴趣我到时候也可以在结合Grafana做一些图表方面的介绍,后面等介绍完Beats以后我去阿里云租几台机器 ...
- Windows rundll32的用法-批处理管理打印机
用法: rundll32 printui.dll,PrintUIEntry [options] [@commandfile] /a[file] 二进制文件名 /b[name] 基本打印机名 /c[na ...
- vuex 状态管理 通俗理解
解释:集中响应式数据管理,一处修改多处使用,主要应用于大中型项目. 安装: 第一:index.js:(注册store仓库) npm install vuex -D // 下载vuex import V ...
- 【问题解决方案】Github中的jupyter notebook文件(.ipynb)加载失败/失败
两个方法: 法一:本机安装jupyter notebook的情况下直接下载文件并打开 本机打开的话会在浏览器中显示,地址为localhost:8888,也就是本机 法二:在线打开:利用 'https: ...
- Java的常量和变量
一.标识符 如类名,数字不能作为标识符的首字母(以字母或者下划线或者$开头且不能有空格) 注意和Python的区别,Python中标识符由字母.下划线和数字组成,且数字不能开头,也是严格区分大小写(但 ...
- Windows平台安装TensorFlow Q&A
·本文讲的是Windows平台使用原生pip进行TensorFlow(CPU版本)安装的注意事项及常见问题解决方法 ·这是TensorFlow官网的安装介绍:在 Windows 上安装 TensorF ...
- Python基础:数据类型-数字(5)
在Python中,所有的数据类型都是类,每一个变量都是类的实例. Python中有6种标准数据类型:数字(Number).字符串(String).列表(List).元组(Tuple).集合(Sets) ...
- ubuntu beyond compare到期后续期
rm -f /home/agu/.config/bcompare/registry.dat 或者加入定时任务,每天10:00执行 crontab -e * 10 * * * rm -f /home/a ...