el-date-picker时间选择器
<el-date-picker
v-model="rangeTime"
:editable="false"
type="daterange"
range-separator="至"
start-placeholder="请选择开始日期"
end-placeholder="请选择开始日期"
:picker-options="pickerOptions"
format="yyyy-MM-dd "
value-format="yyyy-MM-dd"
@change="handleChangeDate"
>
</el-date-picker>
data中return
包含当月:
pickerOptions: {
disabledDate: time => {
const sixMonth = new Date().setMonth(new Date().getMonth() - 5)
return time.getTime() > Date.now() || time.getTime() < sixMonth
}
},
不包含当月:
pickerOptions: {
disabledDate: time => {
const sixMonth = new Date().setMonth(new Date().getMonth() - 6)
return time.getTime() + (30 * 24 * 3600 * 1000) > Date.now() || time.getTime()
< sixMonth
}
},
下一篇有封装好的,更实用的。两者不同