// 深拷贝
deepCopy (obj) {
if(obj instanceof Date){
// 注意 JSON.stringify 转Date类型时 会少8小时
return new Date(new Date(obj).valueOf());
}
var result = Array.isArray(obj) ? [] : {};
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'object' && obj[key]!==null) {
result[key] = this.deepCopy(obj[key]); //递归复制
} else {
result[key] = obj[key];
}
}
}
return result;
}