"Object doesn't support property or method 'shift'" in IE on Focus to JQuery Datepicker(仅在 month/year 更改后)

"Object doesn't support property or method 'shift'" in IE on Focus to JQuery Datepicker (Only after month/year is changed)

我有一个使用 AngularJS 指令的 JQuery Datepicker,datepiker 在 Chrome/FireFox/Edge 中工作正常,但在 IE 中半工作。

问题是输入时会出现日期选择器日历,你可以选择一个日期,它关闭,选择另一个,可以。但只有当日期是当前 month/year 时,一旦更改月份或年份,您最初可以选择一个日期,它会出现在输入中,但任何后续尝试使日历出现都失败,单击进入控制台错误的输入结果:

Object doesn't support property or method 'shift'

var App = angular.module('App', ["ui.bootstrap"]).config(['$httpProvider', function ($httpProvider) {   

}]);

App.controller('Form', function ($scope, $http, $timeout, $filter) {});

App.directive('datepicker', function ($timeout) {
  var linker = function (scope, element, attrs, ngModelCtrl) {
      scope: {
          myval: '='
      }
      $timeout(function () {
          $(element).datepicker({
              dateFormat: "DD, d MM, yy",
              yearRange: '1900:+0',
              defaultDate: new Date(2000, 0, 1),
              changeMonth: true,
              changeYear: true,
              //showAnim: "fold",
              onSelect: function (date) {
                  ngModelCtrl.$setViewValue(date);
                  scope.$apply();
              },
              beforeShow: function (element, datepicker) {
                  if (attrs.minDate) {
                      angular.element(element).datepicker("option", "minDate", attrs.minDate);
                  }
                  if (attrs.maxDate) {
                      angular.element(element).datepicker("option", "maxDate", attrs.maxDate);
                  }
              }
          });
      });
  };

  return {
      restrict: 'A',
      require: 'ngModel',
      transclude: true,
      link: linker,
  };

});
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="App">
<div ng-controller="Form">
<input datepicker id="DPID" type="text" min-date="-43800" max-date="-4840" ng-model="Date1" class="form-control" />
</div>

jQueryJavaScript 框架的 3.0 版,[是]第一个完全没有针对旧版 Internet Explorer 浏览器 (IE6-8) 的解决方法的版本。1

来自微软:2

Beginning January 12, 2016, only the most current version of Internet Explorer available for a supported operating system receives technical support and security updates, as shown in the following table:

 Windows Desktop Operating Systems   Internet Explorer Version
 ---------------------------------   -------------------------
 Windows Vista SP2 *                 Internet Explorer 9
 Windows 7 SP1                       Internet Explorer 11
 Windows 8.1 Update                  Internet Explorer 11
 Windows 10**                        Internet Explorer 11

*This product is no longer in support. See the Lifecycle site for end of support dates and migration information.

**Windows 10 features Microsoft Edge. Microsoft recommends using Microsoft Edge as your default browser and supports Internet Explorer 11 for backward compatibility.

我这边重现了这个问题,看来问题和JQuery版本有关,你用的是JQuery3.4.0版本。请尝试使用以下 JQuery 参考:

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>

我也遇到了同样的问题。 改成jQuery3.4.1后,错误不再出现