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>
相关推荐
web守墓人44 分钟前
【前端】ikun-markdown: 纯js实现markdown到富文本html的转换库
前端·javascript·html
序属秋秋秋1 小时前
《C++初阶之内存管理》【内存分布 + operator new/delete + 定位new】
开发语言·c++·笔记·学习
Savior`L1 小时前
CSS知识复习5
前端·css
许白掰1 小时前
Linux入门篇学习——Linux 工具之 make 工具和 makefile 文件
linux·运维·服务器·前端·学习·编辑器
B1nna2 小时前
Docker学习
学习·docker·容器
中微子5 小时前
🔥 React Context 面试必考!从源码到实战的完整攻略 | 99%的人都不知道的性能陷阱
前端·react.js
中微子6 小时前
React 状态管理 源码深度解析
前端·react.js
加减法原则7 小时前
Vue3 组合式函数:让你的代码复用如丝般顺滑
前端·vue.js
promising-w8 小时前
【运算放大器专题】基础篇
嵌入式硬件·学习
宝山哥哥8 小时前
网络信息安全学习笔记1----------网络信息安全概述
网络·笔记·学习·安全·网络安全