<el-date-picker class="search-label"
v-model="datetimeValue"
type="datetimerange"
:picker-options="pickerOptions"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
align="right">
</el-date-picker>
data(){
return {
datetimeValue: '',
defaultValue: [new Date().getTime() - 3600 * 1000 * 24 * 7,new Date().getTime()], // 默认今天的数据;
pickerOptions: {
shortcuts: [{
text: '今天',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(new Date().setHours(0, 0, 0, 0))
picker.$emit('pick', [start, end]);
}
}, {
text: '昨天',
onClick(picker) {
const end = new Date();
const start = new Date();
end.setTime(end.getTime() - 3600 * 1000 * 24);
start.setTime(start.getTime() - 3600 * 1000 * 24 * 2);
picker.$emit('pick', [start, end]);
}
},{
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]);
}
}]
},
}
}
element定义快捷时间选项
最新推荐文章于 2024-03-28 10:55:00 发布