我正在使用这个 jquery 弹出插件从这个链接 https://web.archive.org/web/20170808060543/http://dixso.github.io:80/custombox/在我的 WordPress 网站上。它在所有浏览器上工作正常,但在 IE11 上出现以下错误。
正如其他人提到的,对象.分配() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assignIE 不支持该方法,但有一个可用的 polyfill,只需将其包含在插件声明“之前”即可:
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;
};
}
From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
测试页面:http://jsbin.com/pimixel/edit?html,js,输出 http://jsbin.com/pimixel/edit?html,js,output(只需删除polyfill即可得到与您在页面上遇到的相同错误)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)