React react-native Date plug-in m-date-picker/rmc-date-picker use

Source: Internet
Author: User



Based on React, M-date-picker offers IOS-style date selection in a very similar way to native Datepicker.
Home: Https://github.com/react-component/m-date-picker
Demo:http://react-component.github.io/m-date-picker/examples/popup.html
Recommendation: ★★★★★
Advantages: Smooth use, very similar to native Datepicker, powerful, able to meet general requirements
Insufficient: Temporarily no
------------------



The official demo is based on the internal source code, with the actual NPM I integrated after the use of a different, and now provide the actual reference


npm i rmc-date-picker --s
Based on [email protected] 6.0.8 example
import ‘rmc-picker / assets / index.css’;
import ‘rmc-date-picker / assets / index.css’;
import ‘rmc-picker / assets / popup.css’;
import zh_CN from ‘rmc-date-picker / lib / locale / zh_CN’;
import DatePicker from ‘rmc-date-picker / lib / DatePicker’;
import PopPicker from ‘rmc-date-picker / lib / Popup’;

class Demo extends React.Component {
  constructor (props) {
    super (props);
    this.state = {
      date: null,
    };
  }

  onChange = (date) => {
    console.log (‘onChange’, this.format (date));
    this.setState ({
      date,
    });
  }

   format = (date) => {
        let mday = date.getDate ();
        let month = date.getMonth () + 1;
        month = month <10? `0 $ {month}`: month;
        mday = mday <10? `0 $ {mday}`: mday;
        return `$ {date.getFullYear ()}-$ {month}-$ {mday} $ {date.getHours ()}: $ {date.getMinutes ()}`;
   }

  onDismiss = () => {
    console.log (‘onDismiss’);
  }

  render () {
    const {date} = this.state;
    const datePicker = (
      <DatePicker
        rootNativeProps = {{‘data-xx‘: ‘yy’}}
        minDate = {new Date (2015, 8, 15, 10, 30, 0)}
        maxDate = {new Date (2019, 8, 15, 10, 30, 0)}
        defaultDate = (new Date ())
        mode = {‘date‘}
        locale = {zh_CN}
      />
    );
    return <div style = {{margin: ‘10px 30px’}}>
      <h2> popup date picker </ h2>
      <div>
        <PopPicker
          datePicker = {datePicker}
          transitionName = "rmc-picker-popup-slide-fade"
          maskTransitionName = "rmc-picker-popup-fade"
          title = {‘Choose Date’}
          date = {date}
          okText = {‘Confirm’}
          dismissText = {‘Cancel’}
          onDismiss = {this.onDismiss}
          onChange = {this.onChange}>
          <p> Click me </ p>
         // Trigger the popup display, just put any label here
        </ PopPicker>
      </ div>
    </ div>;
  }
}
---------------------

Original: https://blog.csdn.net/u012982629/article/details/80752409? 




Screenshotsweb










Apidatepicker Props
































React react-native Date plug-in m-date-picker/rmc-date-picker use


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.