vue:
<a-col :md="5" :sm="24">
<a-form-item>
<a-range-picker
:ranges='timeRange'
:default-value="[
moment().startOf('month'),
moment().startOf('day'),
]"
style="width: 400px"
name='binded_at'
:show-time="{
hideDisabledOptions: true
}"
:placeholder="['結束時間起點', '結束時間終點']"
format='YYYY-MM-DD'
@change="endTimeChange"
/>
</a-form-item>
</a-col>

data():

timeRange:
{
今天: [moment().startOf('day'), moment()],
昨天: [moment().startOf('day').subtract(1, 'days'), moment().endOf('day').subtract(1, 'days')],
最近三天: [moment().startOf('day').subtract(2, 'days'), moment().endOf('day')],
最近一週: [moment().startOf('day').subtract(1, 'weeks'), moment()],
本月: [moment().startOf('month'), moment()],
本年: [moment().startOf('year'), moment()]
},


trainForm: {
dateRange: {
beginTime: moment().startOf('month').format('YYYY-MM-DD'),
endTime: moment().startOf('day').format('YYYY-MM-DD')
}
},


methods:
moment,
createChange(dates, dateStrings) {
this.trainForm.dateRange.beginTime = dateStrings[0]
this.trainForm.dateRange.endTime = dateStrings[1]
},



before request:
if (this.trainForm.dateRange) {
this.queryParam.start_at_range = this.trainForm.dateRange.beginTime + ',' + this.trainForm.dateRange.endTime
}

作者:​​ukyo--阿涅丝​​