其他分享
首页 > 其他分享> > Element-ui el-date-picker 禁止点击的日期

Element-ui el-date-picker 禁止点击的日期

作者:互联网

1.关于月份的日期禁用

<template>
	<el-date-picker
	   v-model="dataForm.serviceMonth"
	   type="month"
	   value-format="yyyy-MM"
	   :picker-options="pickerOptions"
	   placeholder="选择月">
	 </el-date-picker>
</template>
<script>
export default {
	data () {
    	return {
    	dataForm:{},
    	projectInfo:{},
    	pickerOptions: {
	        disabledDate: this.disabledDate
	    },
   	},
   	methods:{
   		 //禁用日期,只能选择项目开始结束日期范围内的
   		 //针对选择月份的限制
	    disabledDate(time){
	      let stime = new Date(this.projectInfo.start_time).getTime()
	      let etime = new Date(this.projectInfo.end_time).getTime()
	      const minTime = new Date(stime).setMonth(new Date(stime).getMonth())
	      const maxTime = new Date(etime).setMonth(new Date(etime).getMonth())
	
	      return time.getTime() < minTime || time.getTime() > maxTime
	    }
   	}
}
</script>

标签:picker,el,getTime,projectInfo,Element,time,Date,new,etime
来源: https://blog.csdn.net/qq_37919055/article/details/120448885