应用场景:
需要设置快捷时间:近一周、近一月、近三月,但是初始时间为当天0点,结束时间为当天23点59分59秒。
然后我就写了一段这样的:
pickerOptions: {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
const newStart=new Date(start.getFullYear()+'-'+(1+start.getMonth())+'-'+start.getDate()+' 00:00:00');
const newEnd=new Date(end.getFullYear()+'-'+(1+end.getMonth())+'-'+end.getDate()+' 23:59:59');
picker.$emit('pick', [newStart, newEnd]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new