TimePicker: fix doc demo, fixed #92

This commit is contained in:
qingwei.li 2016-09-21 13:39:38 +08:00
parent a61280fbcb
commit 2aef7f5d44
3 changed files with 77 additions and 67 deletions

View File

@ -120,32 +120,34 @@
<script>
export default {
data() {
return {
pickerOptions1: {
shortcuts: [{
text: '今天',
onClick(picker) {
picker.$emit('pick', new Date());
}
}, {
text: '昨天',
onClick(picker) {
const date = new Date();
picker.$emit('pick', date.getTime() - 3600 * 1000 * 24);
}
}, {
text: '一周前',
onClick(picker) {
const date = new Date();
picker.$emit('pick', date.getTime() - 3600 * 1000 * 24 * 7);
}
}]
},
value1: '',
value2: '',
};
return {
pickerOptions1: {
shortcuts: [{
text: '今天',
onClick(picker) {
picker.$emit('pick', new Date());
}
}, {
text: '昨天',
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24);
picker.$emit('pick', date);
}
}, {
text: '一周前',
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', date);
}
}]
},
value1: '',
value2: '',
};
}
};
};
</script>
```
:::
@ -216,36 +218,39 @@
<script>
export default {
data() {
return {
pickerOptions2: {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = end.getTime() - 3600 * 1000 * 24 * 7;
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = end.getTime() - 3600 * 1000 * 24 * 30;
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = end.getTime() - 3600 * 1000 * 24 * 90;
picker.$emit('pick', [start, end]);
}
}]
},
value6: '',
value7: ''
};
return {
pickerOptions2: {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
}]
},
value6: '',
value7: ''
};
}
};
};
</script>
```
:::

View File

@ -77,7 +77,7 @@
padding: 0;
display: flex;
}
.demo-datetime-picker .block {
padding: 30px 0;
text-align: center;
@ -87,7 +87,7 @@
border-right: none;
}
}
.demo-datetime-picker .demonstration {
display: block;
color: #8492a6;
@ -138,13 +138,15 @@
text: '昨天',
onClick(picker) {
const date = new Date();
picker.$emit('pick', new Date(date.getTime() - 3600 * 1000 * 24));
date.setTime(date.getTime() - 3600 * 1000 * 24);
picker.$emit('pick', date);
}
}, {
text: '一周前',
onClick(picker) {
const date = new Date();
picker.$emit('pick', new Date(date.getTime() - 3600 * 1000 * 24 * 7));
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', date);
}
}]
},
@ -192,21 +194,24 @@
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = end.getTime() - 3600 * 1000 * 24 * 7;
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = end.getTime() - 3600 * 1000 * 24 * 30;
picker.$emit('pick', [start, end]);
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = end.getTime() - 3600 * 1000 * 24 * 90;
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
}]

View File

@ -189,11 +189,11 @@
```
:::
## 全局方法
### 全局方法
element 为 Vue.prototype 添加了全局方法 $message。因此在 vue instance 中可以采用本页面中的方式调用 `Message`
## 单独引用
### 单独引用
单独引入 `Message`
@ -203,7 +203,7 @@ import { Message } from 'element-ui';
此时调用方法为 `Message(options)`
## Options
### Options
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------------- |---------- |-------------------------------- |-------- |
| message | 消息文字 | string | — | — |