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

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);

        }

    }

    }

}

你可能感兴趣的:(日期选择限制,只选择当前日期的前一天以及前三个月)