解决IE浏览器报错,对象不支持“assign”属性或方法
报错页面:
报错代码:
解决后:
解决代码:
function doTest() {
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;
};
}
var target = {a : 1}; //目标对象
var source1 = {b : 2}; //源对象1
var source2 = {c : 3}; //源对象2
var source3 = {c : 4}; //源对象3,和source2中的对象有同名属性c
var object = Object.assign(target,source1,source2,source3);
console.log(object);
}
TheEzreal: 返回了多行怎么办,不能用table()函数了,t会报错单行返回了多行。 1 <Collection> 2 <Collection>
前端李十三: 亲测有效
阿sir198: 没有看见那个.exe可执行程序
yhb19980226: 感谢博主提供的方法,成功导入json头文件。之前看别的博客都是下载重新编译静态链接库,都不行。最后想提醒一下后面进来的人,博客中的外部包含目录路径不对,缺少\json。
2301_77602514: 哈喽,大佬,为什么我这里没有高级选项一栏呢?麻烦告知求求了