element ui DateTimePicker 日期时间选择器 只能选择当前以及之后的时间


 

 1 <el-date-picker
 2     v-model="nowTime"
 3     type="datetime"
 4     format="yyyy-MM-dd HH:mm:ss"
 5     value-format="yyyy-MM-dd HH:mm:ss"
 6     placeholder="选择日期时间"
 7     :picker-options="pickerOptions"
 8     @change="handle"
 9 >
10 </el-date-picker> 

 

1 return {
2     nowTime: '',
3     pickerOptions: {
4         disabledDate(time) {
5              return time.getTime() < Date.now(); // 选当前时间之后的时间
6         }
7     }
8 }

选择时间大于当前的系统时间,会重置为当前时间

1 methods:{
2     handle(){
3         new Date().getTime() > new Date(this.nowTime).getTime() && (this.nowTime = new Date());
4     },
5 }    

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM