出现错误:对象不支持属性或方法“分配" [英] Getting Error: Object doesn't support property or method 'assign'

查看:240
本文介绍了出现错误:对象不支持属性或方法“分配"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此jquery弹出插件通过此链接在我的WordPress网站上.在所有浏览器上都可以正常工作,但在IE11上却出现以下错误.

I am using this jquery popup plugin from this link on my WordPress site. It's working fine on all browsers but giving the following error on IE11.

推荐答案

正如其他人所提到的,

As others have mentioned, the Object.assign() method is not supported in IE, but there is a polyfill available, just include it "before" your plugin declaration:

if (typeof Object.assign != 'function') {
  Object.assign = function(target) {
    'use strict';
    if (target == null) {
      throw new TypeError('Cannot convert undefined or null to object');
    }

    target = Object(target);
    for (var index = 1; index < arguments.length; index++) {
      var source = arguments[index];
      if (source != null) {
        for (var key in source) {
          if (Object.prototype.hasOwnProperty.call(source, key)) {
            target[key] = source[key];
          }
        }
      }
    }
    return target;
  };
}

来自 https://developer.mozilla.org/zh- US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

测试页: http://jsbin.com/pimixel/edit?html,js,output(只需移除polyfill即可获得与页面上相同的错误).

Test page: http://jsbin.com/pimixel/edit?html,js,output (just remove the polyfill to get the same error you're getting on your page).

这篇关于出现错误:对象不支持属性或方法“分配"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆