屁大个事 2019-10-24 10:44 采纳率: 0%
浏览 864

laydate旧版本,改变年份最大时间限制,日期控件小时选择为什么不能正常选择?

初始化之后,假如开始时间最大时间限制在2019-10-24 11 改变月份或日期后,最大时间限制正常
如果改变年份的话,最大时间小时选择只能选到11点,不能选择12-23,截图如下:

图片说明
改变月份或日期 与改变年份之后,html元素属性一致,截图:

图片说明

laydate在angularjs中的封装:

.directive('myLayDate', function ($timeout) {
      return {
        require: '?ngModel',
        restrict: 'AE',
        scope: {
          ngModel: '=',
          choose: '&',
          min: '@',
          max: '@',
          istime: '@',
          format: '@',
          isclear: '@',
          istoday: '@',
          issure: '@',
          festival: '@',
          start: '@',
          fixed: '@'
        },
        link: function (scope, element, attr, ngModel) {
          $timeout(function(){
            ngModel.$render = function () {
              element.val(ngModel.$viewValue || '');
            };

            element.on('blur keyup change', function () {
              scope.$apply(read);
            });

            function read() {
              var val = element.val();
              ngModel.$setViewValue(val);
            }

            if (attr.skin) {
              laydate.skin(attr.skin);
            } else {
              laydate.skin('yahui');
            }

            scope.option = {
              elem: '#' + attr.id,
              format: scope.format != undefined && attr.format != '' ? attr.format : 'YYYY-MM-DD',
              istime: scope.istime,//是否开启时间选择
              timerange: scope.timerange || 'hms',
              isclear: scope.isclear, //是否显示清空
              istoday: scope.istoday, //是否显示今天
              issure: scope.issure || true, //是否显示确认
              festival: scope.festival, //是否显示节日
              min: scope.min || '1900-01-01 00:00:00', //最小日期
              max: scope.max || '2099-12-31 23:59:59', //最大日期
              start: scope.start || '2014-6-15 23:00:00',    //开始日期
              fixed: scope.fixed, //是否固定在可视区域
              zIndex: 99999999, //css z-index
              choose: function (data) {
                scope.$apply(read);
                scope.$apply(scope.choose);
              }
            };

            function init() {
              laydate(scope.option);
            }

            init();
            if(scope.start){
              element.val(scope.start);
            }


            scope.$watch('min', function (newValue, oldValue) {
              if (newValue == oldValue)
                return;
              scope.option.min = newValue;
            });

            scope.$watch('max', function (newValue, oldValue) {
              if (newValue == oldValue)
                return;
              scope.option.max = newValue;
            });

            scope.$watch('format', function (newValue, oldValue) {
              if (newValue == oldValue)
                return;
              scope.option.format = newValue;
              read();
            });

            read();
          },0);
        }
      }
    });

html代码:

//开始时间
<input type="text"
                           my-lay-date=""
                           class="laydate-icon"
                           autocomplete="off"
                           id="startDate"
                           ng-model="startDate.value"
                           start={{startDate.value}}
                           istime="{{istime}}"
                           max="{{startDate.max}}"
                           min="{{startDate.min}}"
                           format="{{datetimeformat}}"
                           timerange="{{timerange}}"
                           choose="startselect()"/> 
//结束时间
<input type="text" my-lay-date=""
                           class="laydate-icon"
                           autocomplete="off"
                           id="endDate"
                           ng-model="endDate.value"
                           start="{{endDate.value}}"
                           istime="{{istime}}"
                           format="{{datetimeformat}}"
                           min="{{endDate.min}}"
                           max="{{endDate.max}}"
                           timerange="{{timerange}}"/>

js代码:

$scope.startDate = {
            'value': moment().format('YYYY-MM-DD HH'),
            'max': moment().format('YYYY-MM-DD HH'),
            'min': '1951-01-01 00'
        };  //开始时间设置
        $scope.endDate = {
            'value': moment().format('YYYY-MM-DD HH'),
            'min': $scope.startDate.value,
            'max': moment().add(1, 'hours').format('YYYY-MM-DD HH')
        };  //结束时间设置

请问这是什么原因?

  • 写回答

1条回答

  • zqbnqsdsmd 2019-10-24 13:05
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)