浏览代码

修改readme文件

胡耀汉 8 年之前
父节点
当前提交
94f840d505
共有 4 个文件被更改,包括 92 次插入8 次删除
  1. 62 6
      README.md
  2. 1 1
      react/assets/app.bundle.js
  3. 27 0
      react/entry/app.js
  4. 2 1
      react/package.json

+ 62 - 6
README.md

@@ -11,10 +11,18 @@
 3. 历史记录选择日期
 4. 支持tag标识
 5. 支持选择日期回调
-6. 屏幕适应
+6. 支持上一月/下一月选择回调
+7. 支持tags动态切换
+8. 屏幕适应
 
 ---------------------
 
+## 安装方式
+```javascript
+npm install
+npm run start
+```
+
 ## react 调用方式
 
 ```javascript
@@ -23,13 +31,61 @@ import ReactDOM from 'react-dom';
 import Calendar from './Calendar';
 
 const App = React.createClass({
+
+    /**
+     * 初始状态
+     * @returns {{tags: number[]}}
+     */
+    getInitialState() {
+        return {
+            tags : [5, 21]
+        }
+    },
+
+    /**
+     * 选择日期
+     * @param year
+     * @param month
+     * @param day
+     */
+    selectDate(year, month, day) {
+        console.log("选择时间为:" + year + '年' + month + '月' + day + '日' );
+    },
+
+    /**
+     * 上一个月
+     * @param year
+     * @param month
+     */
+    previousMonth(year, month) {
+        console.log("当前日期为:" + year + '年' + month + '月');
+        this.setState({tags : [7, 11]});
+    },
+
+    /**
+     * 下一个月
+     * @param year
+     * @param month
+     */
+    nextMonth(year, month) {
+        console.log("当前日期为:" + year + '年' + month + '月');
+        this.setState({tags : [8, 23]});
+    },
+
+    /**
+     * 组件渲染
+     * @returns {XML}
+     */
     render() {
         return (
-            <Calendar onSelectDate={this.selectDate} 
-                year='2016' 
-                month='8' 
-                day='7' 
-                tags={[5, 22]} />
+            <Calendar
+                onSelectDate={this.selectDate}
+                onPreviousMonth={this.previousMonth}
+                onNextMonth={this.nextMonth}
+                year="2016"
+                month="8"
+                day="7"
+                tags={this.state.tags} />
         );
     }
 });

文件差异内容过多而无法显示
+ 1 - 1
react/assets/app.bundle.js


+ 27 - 0
react/entry/app.js

@@ -11,23 +11,50 @@ import Calendar from '../components/Calendar';
 
 const App = React.createClass({
 
+    /**
+     * 初始状态
+     * @returns {{tags: number[]}}
+     */
     getInitialState() {
         return {
             tags : [5, 21]
         }
     },
 
+    /**
+     * 选择日期
+     * @param year
+     * @param month
+     * @param day
+     */
     selectDate(year, month, day) {
         console.log("选择时间为:" + year + '年' + month + '月' + day + '日' );
     },
+
+    /**
+     * 上一个月
+     * @param year
+     * @param month
+     */
     previousMonth(year, month) {
         console.log("当前日期为:" + year + '年' + month + '月');
         this.setState({tags : [7, 11]});
     },
+
+    /**
+     * 下一个月
+     * @param year
+     * @param month
+     */
     nextMonth(year, month) {
         console.log("当前日期为:" + year + '年' + month + '月');
         this.setState({tags : [8, 23]});
     },
+
+    /**
+     * 组件渲染
+     * @returns {XML}
+     */
     render() {
         return (
             <Calendar

+ 2 - 1
react/package.json

@@ -4,7 +4,8 @@
   "description": "react calendar",
   "main": "webpack.config.js",
   "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1"
+    "test": "echo \"Error: no test specified\" && exit 1",
+    "start": "webpack --progress -w --colors"
   },
   "keywords": [
     "calendar"