This article example shares the specific code for using Element+vue to implement start and end time limits for your reference. The specific content is as follows Effect <el-form-item label="Start time"> <el-date-picker v-model="startDate" type="datetime" placeholder="Select a date" format="yyyy-MM-dd HH:mm:ss" value-format="timestamp" :editable="false" :picker-options="pickerOptionsStart" @change="changeStart"> </el-date-picker> </el-form-item> <el-form-item label="End time"> <el-date-picker v-model="endDate" type="datetime" placeholder="Select a date" style="width: 100%;" format="yyyy-MM-dd HH:mm:ss" value-format="timestamp" :clearable="true" :editable="false" :picker-options="pickerOptionsEnd" @change="changeEnd"> </el-date-picker> </el-form-item> pickerOptionsStart: {}, pickerOptionsEnd: {}, startDate: '', endDate: '', changeStart() { // Limit the start time if (this.endDate != '') { if (this.endDate <= this.startDate) { this.$message.warning('End time must be greater than start time!'); this.startDate = ''; } } this.pickerOptionsEnd = Object.assign({}, this.pickerOptionsEnd, { disabledDate: (time) => { if (this.startDate) { return time.getTime() < this.startDate; } }, }); }, changeEnd() { // Limit end time console.log(this.endDate); if (this.startDate != '') { if (this.endDate <= this.startDate) { this.$message.warning('End time must be greater than start time!'); this.endDate = ''; } } this.pickerOptionsStart = Object.assign({}, this.pickerOptionsStart, { disabledDate: (time) => { if (this.endDate) { return time.getTime() > this.endDate; } }, }); }, The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Nginx installation error solution
>>: Analysis of Linux configuration to achieve key-free login process
Preface Arrays are a special kind of object. Ther...
I believe everyone is very sensitive to colors. C...
The crontab command is used by Unix and Linux to ...
Preface When a 403 cross-origin error occurs No &...
Directly to the configuration file server { liste...
The previous article introduced a detailed exampl...
Situation description: The database was started a...
Table of contents Build Vuex environment Summariz...
Preface Usually, a "paging" strategy is...
Recently, I need to package the project for membe...
Three ways to configure Nginx The first method di...
Table of contents 1. Location / Matching 2. Locat...
All blogs listed below are original and uniquely ...
Today is another very practical case. Just hearin...
Customize a demo command The syntax of Vue custom...