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 组件布局.组件与 ...
随机推荐
- sqlserver简便创建用户并授权
很多研发人员程序连接SQL Server直接用的就是SA帐号.如果对数据库管理稍微严格一点的话,就不应该给应用程序这种权限,通常应用程序只需要进行增删改查,而很少有DDL操作,因此配置帐号时应该遵循“ ...
- JS直接调用C#后台方法(ajax调用)
1. 先手动引用DLL或者通过NuGet查找引用,这里提供一个AjaxPro.2.dll的下载: 2. 之后的的过程不想写了,网上都大同小异的,直接参考以前大佬写的: AjaxPro2完整入门教程 总 ...
- TiDB 架构及设计实现
一. TiDB的核心特性 高度兼容 MySQL 大多数情况下,无需修改代码即可从 MySQL 轻松迁移至 TiDB,分库分表后的 MySQL 集群亦可通过 TiDB 工具进行实时迁移. 水平弹性扩展 ...
- ILRuntime官方Demo笔记
调用/执行 热更中的方法 调用热更代码中方法,写在AppDomain中,记录一下主要几个方法: AppDomain.LoadAssembly 加载热更dll 执行热更代码的方法,有两种方式: appd ...
- mysql No query specified
MySQL SHOW CREATE TABLE tablename \G; 会出现 ERROR: No query specified 原因 去掉分号 ; \g \G三者选其一即可.
- Linux Mint如何添加windows分享的网络打印机?
1.安装samba sudo apt-get install samba 2.找到系统打印机选项 通过 Menu-->>控制中心-->>系统管理找到 Printers选项,双击 ...
- flask轻量级框架入门
# -*- encoding: utf-8 -*- #导入Flask类, 导入重定向,url_for是简易寻址跳转, from flask import Flask,redirect,url_for, ...
- day07(数据类型的相互转换 ,字符编码)
一,复习: ''' 1,深浅拷贝 ls = [1,'a',[10]] 值拷贝:直接赋值 ls1 = ls,ls中的任何值发生改变,ls1也随之发生改变 浅拷贝:通过copy()方法 ls2 = ls. ...
- CodeForces Round #554 Div.2
A. Neko Finds Grapes 代码: #include <bits/stdc++.h> using namespace std; ; int N, M; int a[maxn] ...
- Python——pyqt5——各框架编程
一.日期时间(dateTimeEdit/dateEdit) setDateTime:设置日期(含时间) QDateTime.currentDateTime():当前日期(含时间) setDate:设置 ...