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

 

posted @ 2022-08-10 17:20  shuihanxiao  阅读(1859)  评论(0)    收藏  举报