其他分享
首页 > 其他分享> > element el-date-picker 选择指定月份

element el-date-picker 选择指定月份

作者:互联网

el-date-picker 选择指定月份范围

<el-date-picker
v-model="value2"
type="month"
placeholder="选择月"
:picker-options="pickerOptions"
>
</el-date-picker>

data(){
  return{
     creactMothArr:['2020-05,'2020-04'],
     pickerOptions:{
       disabledData:(time)=>{
        const year = time.getFullYear()
        const month= time.getMonth()+1
        if(month<10) month = '0' + month
        const ym = year +'-'+month
        //把所有年月和需要建立的月份匹配,把没有匹配上的返回出去,让月份 
        //选择器可以选
        return this.creactMothArr.includes(ym)
      }
    }
  }  
    

 

标签:picker,el,const,month,time,date,element
来源: https://www.cnblogs.com/shuihanxiao/p/16573198.html