v-model="ruleForm.lsExpireTime" :disabled-date="disabledDateFun" :disabled-hours="disabledHours" :disabled-minutes="disabledMinutes" :disabled-seconds="disabledSeconds" :default-time="new Date()" type="datetime" placeholder="日期" @change="expireTimeChange" /> const expireTimeChange = (value) => { if (value) { ruleForm.expireTime = new Date(value).getTime(); } }; const disabledDateFun = (time: Record // this.pickerOptions.selectableRange = `${currentTime} - 23:59:59` return time.getTime() < Date.now() - 8.64e7; //时间范围必须大于今天 } const disabledHours = () => { const a = for (let i = 0; i < 24; i++) { // 限制之前 < 之后 > ,下面同理 if (new Date().getHours() <= i) continue; a.push(i); } return a; }; const disabledMinutes = () => { const a = for (let i = 0; i < 60; i++) { // 限制之前 < 之后 > ,下面同理 if (new Date().getMinutes()+5 <= i) continue; //选择默认时间+5分钟 a.push(i); } return a; }; const disabledSeconds = () => { const a = for (let i = 0; i < 60; i++) { // 限制之前 < 之后 > ,下面同理 if (new Date().getSeconds() <= i) continue; a.push(i); } return a; }; // const defaultTime = ref([new Date(10,10,20,23,59,59)]) const defaultTime = () => { var now = new Date(); // 获取当前日期和时间 now.setHours(now.getHours()); // 设置小时为8(24小时制) now.setMinutes(now.getMinutes()+5);//默认时间+5分钟 now.setSeconds(0); return now } // const datePicker = ref({ // disabledDate(time) { // return time.getTime() > Date.now() // }, // defaultTime:[ // new Date(2000, 1, 1, 0, 0, 0), // new Date(2000, 2, 1, 23, 59, 59), // ], // shortcuts: [ // { // text: '30分钟', // value: () => [Date.now() - 30 * 60 * 1000, Date.now()] // }, // { // text: '1小时', // value: () => [Date.now() - 60 * 60 * 1000, Date.now()] // }, // { // text: '3小时', // value: () => [Date.now() - 3 * 60 * 60 * 1000, Date.now()] // }, // { // text: '6小时', // value: () => [Date.now() - 6 * 60 * 60 * 1000, Date.now()] // }, // { // text: '12小时', // value: () => [Date.now() - 12 * 60 * 60 * 1000, Date.now()] // }, // { // text: '1天', // value: () => [Date.now() - 1 * 24 * 3600 * 1000, Date.now()] // }, // { // text: '3天', // value: () => [Date.now() - 3 * 24 * 3600 * 1000, Date.now()] // }, // { // text: '7天', // value: () => [Date.now() - 7 * 24 * 3600 * 1000, Date.now()] // }, // { // text: '15天', // value: () => [Date.now() - 15 * 24 * 3600 * 1000, Date.now()] // }, // { // text: '31天', // value: () => [Date.now() - 31 * 24 * 3600 * 1000, Date.now()] // } // ] // })