IE浏览器不兼容Object.assign()的解决方案

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://my.oschina.net/u/3828418/blog/2056310

你可能感兴趣的:(IE浏览器不兼容Object.assign()的解决方案)