element ui 时间控件
pickerOptions: {
shortcuts: [
{
text: "昨天",
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 1);
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]);
}
},
{
text: "本月",
onClick(picker) {
const now = new Date();
const end = new Date();
const start = new Date(now.setDate(1));
end.setTime(new Date(now.getFullYear(), now.getMonth() + 1, 0));
picker.$emit("pick", [start, end]);
}
}
]
},
pickerOptions: { shortcuts: [ { text: "昨天", onClick(picker) { const end = new Date(); const start = new Date(); start.setTime(start.getTime() - 3600 * 1000 * 24 * 1); 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]); } }, { text: "本月", onClick(picker) { const now = new Date(); const end = new Date(); const start = new Date(now.setDate(1)); end.setTime(new Date(now.getFullYear(), now.getMonth() + 1, 0)); picker.$emit("pick", [start, end]); } } ] },