How to customize the validation date-time Selector for Vue
This article mainly introduces Vue how to customize the verification date-time selector related knowledge, the content is detailed and easy to understand, the operation is simple and fast, with a certain reference value, I believe you will have something to gain after reading this Vue how to customize the verification date-time selector article, let's take a look at it.
Date-time selector for Vue custom validation
Custom verification of today's demand expected effect practical information value-format effect recommendation
Today's demand
In the query condition, when the start time and the end time are the same, the end time is greater than the start time.
Expected effect
Practical information export default {data () {/ / Custom Verification rules var createTimeCheck = (rule, value) Callback) = > {if (value = ='') {callback () / / callback function} else {let createTimeStart = this.createTime? This.createTime [0]:''/ / fetch start time from the array results: '2020-10-28 16 this.createTime 01 let createTimeEnd 15'? This.createTime [1]:'/ / end time of withdrawal let sTime = ((createTimeStart.split ('')) [1]). Split (':)). Join (') / from '2020-10-28 16 rides 01lav 15' take out time result: '160115' let sDate = ((createTimeStart.split (')) [0]) .split ('-') .join ('') / take-out start date result: '20201028' let endTime = (createTimeEnd.split (')) [1]). Split (':)) .join (') / / end time of withdrawal let endDate = ((createTimeEnd.split (')) [0]) .split ( ) .join (') / pull out end date if (parseInt (endDate) > parseInt (sDate)) {/ / if the end date is greater than the start date, do not judge the time callback ()} else {if (parseInt (endTime)) { Const endDateVal = new Date (this.timerEnd). GetTime () If (endDateVal) {return time.getTime () > endDateVal + 1;}, pickerOptionsEnd: {disabledDate: time = > {const beginDateVal = new Date (this.timerStart) .getTime () If (beginDateVal) {return time.getTime () < beginDateVal + 1;};}
This is the end of the article on "how to customize the validation date-time selector for Vue". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to customize the date and time selector for Vue". If you want to learn more, you are welcome to follow the industry information channel.