修改版Demo:
optionsDate: {
shortcuts: [
{
text: '一周卡',
value () {
const end = new Date();
const start = new Date();
// end.setTime(start.getTime() + 3600 * 1000 *24 * 7);
end.setDate(start.getDate() + 7);
return [start, end];
}
},
{
text: '一月卡',
value () {
const end = new Date();
const start = new Date();
// end.setTime(start.getTime() + 3600 * 1000 * 24 * 30);
end.setMonth(start.getMonth() + 1);
return [start, end];
}
},
{
text: '3月卡',
value () {
const end = new Date();
const start = new Date();
// end.setTime(start.getTime() + 3600 * 1000 * 24 * 90);
end.setMonth(start.getMonth() + 3);
// console.log(end);
return [start, end];
}
}
]
},
原始demo:
<template>
<Row>
<Col span="12">
<DatePicker type="daterange" :options="options2" placement="bottom-end" placeholder="Select date" style="width: 200px"></DatePicker>
</Col>
</Row>
</template>
<script>
export default {
data () {
return {
options2: {
shortcuts: [
{
text: '1 week',
value () {
const end = new Date();
const start = new Date();
end.setTime(start.getTime() + 3600 * 1000 * 24 * 7);
return [start, end];
}
},
{
text: '1 month',
value () {
const end = new Date();
const start = new Date();
end.setTime(start.getTime() + 3600 * 1000 * 24 * 30);
return [start, end];
}
},
{
text: '3 months',
value () {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() + 3600 * 1000 * 24 * 90);
return [start, end];
}
}
]
}
}
}
}
</script>