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>
相关推荐
ZhengEnCi7 分钟前
Q04-Vite禁用CSS代码分割-解决生产环境样式加载顺序混乱问题
前端·vue.js·vite
九酒38 分钟前
AI Agent 开发踩坑记:口播功能非得用 APP 原生实现吗?
前端·人工智能·agent
Jackson__1 小时前
做了一段时间的AI coding后,我终于搞清了 CLI 和 MCP 的区别
前端·agent·ai编程
IT_陈寒4 小时前
JavaScript项目实战经验分享
前端·人工智能·后端
用户47949283569155 小时前
6w star,GitHub 趋势第一的 Ponytail,这个agent插件到底在火什么
前端·后端
薛定喵的谔6 小时前
我开源了一个精致的 Next.js 博客模板:Skyplume
前端·前端框架·next.js
张龙6876 小时前
构建生产级 AI Agent:工具调用与记忆架构实战指南
前端
kyriewen7 小时前
2026 年了,还在用 Node.js?Bun 迁移实战:20 分钟搞定,附踩坑记录
前端·javascript·node.js
青山Coding9 小时前
Cesium应用(八):物体运动的实现思路
前端·cesium
用户41659673693559 小时前
Android WebView 加载 file:// 离线页面调试教程
android·前端