日期选择限制,只选择当前日期的前一天以及前三个月

2019-10-31  本文已影响0人  demoxjl

<el-date-picker v-model="value1" type="date" placeholder="选择日期" :options="limitDate"></el-date-picker>

data(){

    return{

        limiDate:{

        disabledDate(date){

            const curDate = new Date();

            let year = curDate.getFullYear();

            let month = curDate.getMonth() +1;

            let day =1;

            let currentDay = curDate.getDate();

            let nextMonth = month +1;

            let preThreeMonth = month - 3;

            let currentDate = year + '-' + month + '-' + currentDay;

            let preThreeDate = year + '-' + preThreeMonth + '-' + day;

            //valueOf()返回Date对象的原始值

            return date.valueOf() < (Date.parse(preThreeDate)) || date.valueOf() > (Date.parse(currentDate) - 86400000);

        }

    }

    }

}

上一篇 下一篇

猜你喜欢

热点阅读