element 中设置el-date-picke 禁用未来时间选择置灰

2024-01-18 20:50:34 浏览数 (4)

代码语言:javascript复制
<el-date-picker
  v-model="form.date"
   value-format="timestamp"
   type="daterange"
   range-separator="至"
   start-placeholder="开始日期"
   end-placeholder="结束日期"
   :picker-options="pickerOptions"
 >
 </el-date-picker>

data(){
  return{
    pickerOptions: {
       disabledDate (time) {
         // 禁用今日后的未来时间
         return time.getTime() > Date.now() - 8.64e6
       },
  }
}

1 人点赞