Coder Social home page Coder Social logo

react-datepicker's Introduction

react-datepicker

DatePicker

日历组件,兼容PC端和移动端,支持日历的基本操作

安装方式

npm install / yarn

npm start

使用方法及配置

import React, { Component } from 'react'
import Calendar from './datepicker'

class ShowDatepicker extends Component {
  constructor(props) {
    super(props)
    this.state = {
      tags: [3, 4, 5, 6]
    }
  }
  selectDate(year, month, day) {
    console.log('选择时间为:' + year + '年' + month + '月' + day + '日')
  }
  previousMonth(year, month) {
    console.log('当前日期为:' + year + '年' + month + '月')
    this.setState({ tags: [7, 11] })
  }
  nextMonth(year, month) {
    console.log('当前日期为:' + year + '年' + month + '月')
    this.setState({ tags: [8, 23] })
  }
  render() {
    const date = new Date()
    return (
      <Calendar
        onSelectDate={this.selectDate}
        onPreviousMonth={this.previousMonth}
        onNextMonth={this.nextMonth}
        year={date.getFullYear()}
        month={date.getMonth() + 1}
        day={date.getDate()}
        tags={this.state.tags} />
    )
  }
}

export default ShowDatepicker

选择日期回调

onSelectDate(year, month, day){

}

选择上个月回调

onPreviousMonth(year, month){

}

选择下个月回调

onNextMonth(year, month){

}

高亮'今天'以及选择日期

year/month/day

tags动态切换

tags

效果

显示日历

文本框操作日历

react-datepicker's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.