Vue 学习随笔系列二十三 -- el-date-picker 组件

el-date-picker 组件


文章目录

  • [el-date-picker 组件](#el-date-picker 组件)
    • [el-date-picker 只有某些日期可选](#el-date-picker 只有某些日期可选)

el-date-picker 只有某些日期可选

bash 复制代码
<template>
  <div>
    <el-form 
      ref="form" 
      size="mini"
      :model="form" 
      :rules="rules"
      label-width="80px"
    >
      <el-row>
        <el-col :span="8">
          <el-form-item label="统计时间" prop="date">
            <el-date-picker
              type="date"
              clearable
              v-model="form.date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期"
              style="width: 100%;"                
              :picker-options="pickerOptions"

            >
            </el-date-picker> 
          </el-form-item>
        </el-col>
        
      </el-row>
    </el-form>
  </div>
</template>

<script>

export default {
  data() {
    return {
      form: {
        date: "",
      },
      allowedDates: ['2024-12-01', '2024-12-05', '2024-12-10'],
    }
  },
  mounted() {
 
  },
  computed: {
    // 日期可选项处理
    pickerOptions(time) {
      const _this = this
      return {
        disabledDate(time) {
          const date = _this.$moment(time).format("YYYY-MM-DD");
          return !_this.allowedDates.includes(date)
        }
      }
    }
  },
  methods: {
    
  }
}
</script>

<style lang="less" scoped>

    .el-date-picker, .el-select {
        width: 100%;
    }
</style>
相关推荐
一尘之中1 小时前
从C语言底层设计到系统架构评估:软件架构知识体系全景
学习·系统架构·ai写作
NiceCloud喜云1 小时前
Opus 4.8 的 Effort Control 怎么选:Low 到 Max 五档策略
android·java·大数据·前端·c++·python·spring
wordbaby2 小时前
React Native + RNOH:跨页面数据回传的最佳实践与避坑指南
前端·react native
丷丩2 小时前
MapLibre GL JS第22课:查看本地GeoJSON
前端·javascript·map·mapbox·maplibre gl js
星夜夏空993 小时前
FreeRTOS学习(4)——内存映射
数据库·学习·mongodb
Front思3 小时前
AI前端工程师需要具备能力+
前端·人工智能·ai
不羁的木木3 小时前
ArkWeb实战学习笔记05-综合实战:构建混合应用
笔记·学习·harmonyos
橙橙笔记3 小时前
Python的学习第一部分
python·学习
bush43 小时前
嵌入式linux学习记录二
linux·运维·学习
ZC跨境爬虫5 小时前
跟着 MDN 学CSS day_29:(掌握文本与字体样式的核心艺术)
前端·css·ui·html·tensorflow