mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-19 09:25:53 +08:00
commit message
This commit is contained in:
27
manager/src/utils/index.js
Normal file
27
manager/src/utils/index.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as regular from './regular'
|
||||
|
||||
export {
|
||||
regular
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数组对象深拷贝
|
||||
* @param obj
|
||||
* @returns {*}
|
||||
*/
|
||||
export default function cloneObj(obj) {
|
||||
let str = null
|
||||
let newobj = obj.constructor === Array ? [] : {}
|
||||
if (typeof obj !== 'object') {
|
||||
return
|
||||
} else if (window && window.JSON) {
|
||||
str = JSON.stringify(obj) // 系列化对象
|
||||
newobj = JSON.parse(str) // 还原
|
||||
} else {
|
||||
for (var i in obj) {
|
||||
newobj[i] = typeof obj[i] === 'object' ? cloneObj(obj[i]) : obj[i]
|
||||
}
|
||||
}
|
||||
return newobj
|
||||
}
|
||||
Reference in New Issue
Block a user