element日期时间段选择器的使用心得

摘要:
“0”+(date.getMonth()+1):date.getMonth()+“-”;letD=date.getDate()˂10?

使用时间段

<el-date-picker
// control the different select suitation
          v-if="selectOne == false"
          v-model="inputDate"
          unlink-panels
          type="daterange"
          range-separator="至 "
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
//pickerOption is the unique methods for the daterange DateSelector [ELEMENT DEFINE] :picker-options="pickerOption" >

  data中

 pickerOption: {
// [date] include the maxDate and minDate onPick: (date) => { this.searchChangeDate(date); }, },

  使用时注意转换时间格式,默认{minDate: Thu Jul 01 2021 00:00:00 GMT+0800 (中国标准时间), maxDate: null}←这样的时间格式

// Get the date to filter
    searchChangeDate(date) {
      console.log(date);
      function formatDate(date) {
        // NULL String cannot use the getDate Methods
        if (date) {
          let Y = date.getFullYear() + "-";
          let M =
            (date.getMonth() + 1 < 10
              ? "0" + (date.getMonth() + 1)
              : date.getMonth() + 1) + "-";
          let D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
          return Y + M + D;
        }
        return "";
      }
      this.maxDate = formatDate(date.maxDate);
      this.minDate = formatDate(date.minDate);
      console.log("maxD", this.maxDate, "
minD", this.minDate);
    },

  我使用watch监听inputDate的变化,由此比较时间大小再返回对应数值

watch:{
//... 
   inputDate() {
      let temp = [];
      let tDate = this.inputDate;

// select different dateSelector has different methods
      if (tDate && this.selectOne) {
        const newData = this.tempData.map((key) => {
          if (key.date == tDate) {
            temp.push(key);
          }
        });
        this.tempData = temp;
      }
      if (tDate && this.selectOne == false) {
        let self = this;
        const newDataMult = this.tempData.map((key) => {
          if (key.date < self.maxDate && key.date > self.minDate) {
            temp.push(key);
          }
        });
        this.tempData = temp;
      }
    },
//...
}

  

免责声明:文章转载自《element日期时间段选择器的使用心得》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇源码安装LNMP与搭建Zabbixpostgresql中的rollup下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

sqlserver 使用脚本创建作业

--【作业常用的几个步骤】   EXEC msdb.dbo.sp_delete_job   EXEC msdb.dbo.sp_add_job   EXEC msdb.dbo.sp_add_jobstep   EXEC msdb..sp_add_jobschedule   EXEC msdb.dbo.sp_add_jobserver    EXEC msd...

hwclock和date源码分析

一. hwclock 1.1 hwclock源码在哪里? util-linux 或者busybox 1.2 获取源码 git clone https://github.com/karelzak/util-linux.git 或 git clonegit://git.busybox.net/busybox 1.3 hwclock的源码路径 sys-utils...

简道云--公式与函数的使用教程

公式与函数 在制作表单时,可以设置控件与控件之间的数据联动关系。给例如编辑完单价和数量后,自动计算总价等这样的业务场景提供了支撑。 公式面板左侧可以选择当前表单控件所对应的值,以及所有表单控件所对应的字段名。被选择后,在公式面板中会以反引号包裹的形式显示。 注意:函数在简道云里的设置是大写,即在运用函数的时候,请用纯大写字母。 表单控件与其返回值的数据类型...

java日期转换

在java开发过程中,时间的转换时必须掌握的=========下面把时间转换做个总结,有可能不是很全面 时间格式只有两种 yyyy-MM-DD yyyy/MM/DD 时间的类型:字符串类型、sql类型、util类型、TimeStamp类型 1.Date转换成字符串时间 //Date 转换成字符串 Date date=new Date()...

SQL 时间函数详解

SQLServer时间日期函数详解,SQLServer,时间日期, 1. 当前系统日期、时间 select getdate() 2. dateadd 在向指定日期加上一段时间的基础上,返回新的 datetime 值 例如:向日期加上2天 select dateadd(day,2,'2004-10-15') --返回:2004-10-17 00:00:...

input type date 解决移动端显示placeholder

在最近的一个项目中使用到了html5的一个新标签属性,type="date"时,发现placeholder属性失效无法使用。 如果是这样的效果,那么客户体验是可想而知的差了。 最后想了一下,想到用css+js双保险来搞定它。 方法1: css: input[type="date"]:before{ content:attr(placeholder)...