功能:根据小时/天的切换时间范围在当前日期的一周/一个月
<el-radio-group v-model="time" size="small" @change="getDate">
<el-radio-button label="小时" />
<el-radio-button label="天" />
</el-radio-group>
<el-radio-group v-if="cityTypeShow" v-model="buildType" size="small" style="margin-left:20px" @change="getBuildType">
<el-radio-button label="默认" />
<el-radio-button label="类型" />
</el-radio-group>
<el-date-picker
v-model="dateTime"
type="datetimerange"
range-separator="~"
start-placeholder="开始日期"
end-placeholder="结束日期"
size="small"
class="dateBox"
/>
data() {
return {
time: '天',
buildType: '默认',
dateTime: [ ],数据形式
}
getDateTime() {
const start = new Date()
let year1, month1, day1;
[year1, month1, day1] = [start.getFullYear(), start.getMonth(), start.getDate()]
const date1 = new Date(year1, month1, day1, 7)
this.dateTime.push(date1)
const end = new Date()
let year2, month2, day2
end.setTime(end.getTime() - 24 * 60 * 60 * 1000 * 30);
[year2, month2, day2] = [end.getFullYear(), end.getMonth(), end.getDate()]
const date2 = new Date(year2, month2, day2, 7)
this.dateTime.unshift(date2)
},