Element-ui Date Component DatePicker Set Date selection range picker options

Source: Internet
Author: User

Element-ui provides the DatePicker date selector component, which allows us to easily get to the date, the default selection is all the date can be selected, but in many scenarios we have to limit the date selection, such as travel date can not choose the past date, Limit date range for booking time

The official website provides the picker-options parameter can set the date selection range, the concrete operation looks the code

//page Introduction component, plus picker-options this parameter<el-date-Picker v-model= "Excheckdate"type= "Date":p Icker-options= "Pickeroptions"value-format= "Yyyy-mm-dd"placeholder= "Please select" > </el-date-picker>//the scope defined in JS  //the value of Picker-options is an object whose Disableddate property can be set to a disabled date, with one parameter being the currently selected datedata () {return{pickeroptions: {},//Date Setting Object}}, created {
///Disableddate to TRUE indicates not selectable, false indicates optional This. pickeroptions.disableddate =Disableddate (time) {//set the selectable date to be within one months after todayLet Curdate = (NewDate ()). GetTime ()//This calculates the number of milliseconds in one months, where the average of 30 is used, and the actual number of days per monthLet day = 30 * 24 * 3600 * 1000Let dateregion= Curdate + DayreturnTime.gettime () < Date.now ()-8.64e7 | | Time.gettime () >dateregion//sets the selected date to be less than the current date, less than the return true, and the date is not selectable //return Time.gettime () < Date.now ()-8.64e7 }, }

Take a look at the effect of the application, optional range one months, 8 is the current date

Optional range today and after the date

If you need other effects you can set your own

Element-ui Date Component DatePicker Set Date selection range picker options

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.