输入类型=日期 IE11 的 JQuery 日期选取器 错误:对象不支持属性或方法交换



我使用的是html5标签:

<input type="date" name="date" id="date">

这适用于手机上的微软边缘浏览器,但不适用于互联网浏览器。为了让它在IE11上运行,我添加了以下内容:

<script src="//cdn.jsdelivr.net/webshim/1.14.5/polyfiller.js"></script>
<script>
webshims.setOptions('forms-ext', {types: 'date'});
webshims.polyfill('forms forms-ext');
</script>

当我在IE11中点击日历时,我会收到以下错误:对象不支持属性或方法交换。

我正在使用以下JQuery来源:

<script   src="https://code.jquery.com/jquery-2.2.2.min.js"></script> 
<script   src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script> 

这似乎是webshim中的一个错误。https://github.com/aFarkas/webshim/issues/560陈述了两种可能的解决方案

  1. 重新设置交换功能。我把它放在jquery-swap.js文件中进行了测试,并在jquery之后包含了它

jquery-swap.js:

jQuery.swap = function( elem, options, callback, args ) {
  var ret, name, old = {};
  // Remember the old values, and insert the new ones

  for ( name in options ) {
        old[ name ] = elem.style[ name ];
        elem.style[ name ] = options[ name ];
  }
  ret = callback.apply( elem, args || [] );
  // Revert the old values
  for ( name in options ) {
          elem.style[ name ] = old[ name ];
  }
  return ret;
};

index.html

<script src="https://code.jquery.com/jquery-2.2.2.js"></script>
<script src="js/jquery-swap.js"></script>
  1. 将jquery回滚到1.11.3

如果能清楚地说明依赖关系,那就太好了。

相关内容

最新更新