app.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * Created by Ryn on 2016/8/7.
  3. * 入口文件
  4. */
  5. import '../style/style.css';
  6. import React from 'react';
  7. import ReactDOM from 'react-dom';
  8. import Calendar from '../components/Calendar';
  9. const App = React.createClass({
  10. /**
  11. * 初始状态
  12. * @returns {{tags: number[]}}
  13. */
  14. getInitialState() {
  15. return {
  16. tags : [5, 21]
  17. }
  18. },
  19. /**
  20. * 选择日期
  21. * @param year
  22. * @param month
  23. * @param day
  24. */
  25. selectDate(year, month, day) {
  26. console.log("选择时间为:" + year + '年' + month + '月' + day + '日' );
  27. },
  28. /**
  29. * 上一个月
  30. * @param year
  31. * @param month
  32. */
  33. previousMonth(year, month) {
  34. console.log("当前日期为:" + year + '年' + month + '月');
  35. this.setState({tags : [7, 11]});
  36. },
  37. /**
  38. * 下一个月
  39. * @param year
  40. * @param month
  41. */
  42. nextMonth(year, month) {
  43. console.log("当前日期为:" + year + '年' + month + '月');
  44. this.setState({tags : [8, 23]});
  45. },
  46. /**
  47. * 组件渲染
  48. * @returns {XML}
  49. */
  50. render() {
  51. return (
  52. <Calendar
  53. onSelectDate={this.selectDate}
  54. onPreviousMonth={this.previousMonth}
  55. onNextMonth={this.nextMonth}
  56. year="2016"
  57. month="8"
  58. day="7"
  59. tags={this.state.tags} />
  60. );
  61. }
  62. });
  63. ReactDOM.render(
  64. <App />,
  65. document.getElementById('datePicker')
  66. );