当前时间2023-11-1
效果图:
直接上代码
//html
<el-date-picker
v-model="item.time"
type="datetimerange"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
style="width: 330px"
size="mini"
align="center"
:pickerOptions="timeOption"
/>
//js
data() {
return {
timeOption: {
disabledDate: (time) => {
const oneYearBefore = new Date(
new Date().setFullYear(new Date().getFullYear() - 1)
)
console.log(oneYearBefore, 'oneYearBefore')
console.log(new Date(), 'new Date()')
return time > new Date() || time < oneYearBefore
},
},
}
}