<el-date-picker v-model="ruleForm.begin" type="datetime" placeholder="请输入活动开始时间" @change="begin" /> <el-date-picker v-model="ruleForm.end" type="datetime" placeholder="请输入活动结束时间" @change="end" />
const ruleForm = reactive({ begin: "", end: "", }); const a = new Date(); //获取到当前时间戳 const begin = () => { console.log(a); console.log(ruleForm.begin); if (ruleForm.begin < a) { ruleForm.begin = ""; ElMessage({ message: "该时间已失效", type: "error" }); } }; const end = () => { if (ruleForm.end < a) { ruleForm.end = ""; ElMessage({ message: "该时间已失效", type: "error" }); } else if (ruleForm.end < ruleForm.begin) { ruleForm.end = ""; ElMessage({ message: "结束时间不能在开始时间之前", type: "error" }); } };