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>
相关推荐
程序员大雄学编程21 分钟前
微积分46. 无穷级数四大核心性质:从理论到实践的全方位解析
python·学习·微积分·学习工具
hzxpaipai39 分钟前
企业官网技术架构拆解:前端、后台、数据库、服务器如何协同
前端·数据库·架构
指针常量2 小时前
【RL系列文章】难样本学习等
学习·大语言模型·rl·后训练
深念Y3 小时前
Lenovo XiaoXinAir 14 — 性能模式切换
前端·网络
wuyk5553 小时前
从零吃透Modbus通信|第7章:终极工程整合(模块化架构、双模式主机从机、RTOS适配、量产级模板)
c语言·stm32·学习·架构
计算机魔术师3 小时前
Meta突然杀进第一梯队:一个新模型,把AI推理成本打下来8倍
前端
IT_陈寒3 小时前
Redis缓存雪崩把我坑惨了,这次长记性了
前端·人工智能·后端
风骏时光牛马3 小时前
提示词工程:大模型效能挖掘与指令设计实战
前端
仓三3 小时前
Chrome DevTools MCP 上手:让 Coding Agent 自己调试前端页面
前端·chrome devtools·mcp