发表于: 2021-04-26 19:53:51

2 1979


今天完成的事情:使用了laydate日历控件

明天计划的事情:完成任务

收获:

如何使用laydata日历控件

简单的使用方法可以看文档https://www.layui.com/doc/modules/laydate.html


这里说一下怎么动态的使用

首先声明两个变量并在ngOnInit()创建两个日历控件

  public start: any;
  public end: any;

this.start = laydate.render({
      elem'#start',              //绑定元素
      showBottomfalse,           //是否有底栏按钮组
      theme'#ccc',               //主题颜色
    })

    this.end = laydate.render({
      elem'#end',
      showBottomfalse,
      theme'#ccc',
    })

接着选择时间后用done来获取时间,并给另一个控件设置最大或最小时间

this.start = laydate.render({
      elem'#start',
      showBottomfalse,
      theme'#ccc',
      done: (value: string, dates: any=> {
        var date = new Date(value);
        this.startAt = date.valueOf();
        this.end.config.min = {
          yeardates.year,
          monthdates.month - 1,
          datedates.date,
          hours0,
          minutes0,
          seconds0
        };
        this.end.config.start = {
          yeardates.year,
          monthdates.month - 1,
          datedates.date,
          hours0,
          minutes0,
          seconds0
        };
      }
    })

最后清空按钮把input内容删除,把最大最小时间删除

 clear() {
    var x = document.getElementById('start'as HTMLInputElement
    x.value = ''
    var y = document.getElementById('end'as HTMLInputElement
    y.value = ''
    this.end.config.min = {
      year1921,
      month4,
      date26,
      hours0,
      minutes0,
      seconds0
    };
    this.start.config.max = {
      year2121,
      month4,
      date26,
      hours0,
      minutes0,
      seconds0
    };
    this.end.config.start = {
      year2121,
      month4,
      date26,
      hours0,
      minutes0,
      seconds0
    };
  }



返回列表 返回列表
评论

    分享到