zoukankan      html  css  js  c++  java
  • react native 中时间选择插件

    npm install react-native-datepicker --save
    import DatePicker from 'react-native-datepicker';

    <View>
    <DatePicker
    style={{ 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

    PropDefaultTypeDescription
    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
  • 相关阅读:
    codeforces 349B Color the Fence 贪心,思维
    luogu_2022 有趣的数
    luogu_2320 [HNOI2006]鬼谷子的钱袋
    luogu_1879 [USACO06NOV]玉米田Corn Fields
    SAC E#1
    luogu_1984 [SDOI2008]烧水问题
    luogu_2085 最小函数值
    luogu_1631 序列合并
    luogu_1196 银河英雄传说
    luogu_1037 产生数
  • 原文地址:https://www.cnblogs.com/yuxingxingstar/p/9817874.html
Copyright © 2011-2022 走看看