javascript
<el-date-picker
v-model="formData.meetingTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
style="width: 100%"
placeholder="请选择日期"
clearable
:picker-options="pickerOptions"
>
</el-date-picker>
javascript
<script>
export default {
data(){
return{
//限制当前时间之前的不可选并且最大可选时间不能超过2028-12-31
pickerOptions: {
disabledDate(time) {
const maxDate = new Date('2028-12-31')
return time.getTime() > maxDate.getTime() || time.getTime() < new Date().getTime() - 86400000
},
selectableRange: (() => { //这里是限制时分秒
let data = new Date()
let hour = data.getHours()
let minute = data.getMinutes()
let second = data.getSeconds()
return [`${hour}:${minute}:${second} - 23:59:59`]
})()
},
}
}
}
<script>