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>
相关推荐
小程故事多_802 小时前
拆解SOP+ReAct对话Agent,告别硬编码,解锁智能对话的柔性迭代能力
前端·人工智能·react.js·前端框架
nicole bai2 小时前
vue 自定义模块内容
前端·javascript·vue.js
清水白石0082 小时前
Python 类定义阶段自动注册子类:从 `__init_subclass__` 到插件系统实战
linux·前端·python
用户69371750013843 小时前
Kimi K3 综合能力处于全球第一梯队
android·前端·后端
kitsch0x973 小时前
论文学习_MalSkillBench: A Runtime-Verified Benchmark of Malicious Agent Skills
学习
Z5998178413 小时前
c#软件开发学习笔记--分组、游标与临时表、分页
笔记·学习·c#
anno3 小时前
Agent 新手 Skill 优先级指南:从第一套必装工作流,到专业能力补全
前端·后端
Liora_Yvonne3 小时前
前端请求层到底怎么封?为什么全局 axios 单例越用越难维护
前端
anno3 小时前
别再把文档“一刀切”:用 LangChain.js 做好 RAG 的第一公里
前端·后端
皮卡穆3 小时前
React 中使用 react-org-tree 实现组织结构树
前端·react.js·前端框架