date.vue
3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<template>
<div style="margin: 150px">
<br>
<row>
<i-col span="8">
<!--<i-button @click="setDate">set date</i-button>-->
<date-picker
style="width:200px"
placeholder="请选择日期"
:value.sync="value"
:options="options"
@on-change="change"
:format="format"
:editable="false"
@on-open-change="change2"></date-picker>
</i-col>
<i-col span="8">
<date-picker type="daterange" style="width:200px" placeholder="请选择日期" :value.sync="value2" :options="options2"></date-picker>
</i-col>
</row>
</div>
</template>
<script>
export default {
data () {
return {
// value: new Date(),
value: '2016-12-25',
value2: '',
options2: {
},
options: {
disabledDate(time) {
// console.log(time)
// return time.getFullYear() < 2016;
return time.getTime() < Date.now() - 8.64e7;
// return time && time.valueOf() < Date.now();
},
shortcuts: [
{
text: '今天',
value () {
// return new Date();
return '1/2/19'
},
onClick (picker) {
console.log('点击了今天');
}
},
{
text: '昨天',
value () {
const date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24);
return date;
},
onClick () {
console.log('点击了昨天');
}
},
{
text: '最近三个月',
value () {
const date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
return date;
},
onClick () {
console.log('点击了一周前');
}
}
]
},
format: 'yyyy-MM-dd'
}
},
computed: {},
methods: {
change (date) {
console.log(date)
},
change2 (s) {
// console.log(s)
},
setDate () {
this.value = '2016-12-24'
}
}
}
</script>