vue 深度拷贝 除去空的参数

// 去除数组里面为空的属性及子数组

export function deepCopy (source) {

var result = []

//var result = {}

for (var key in source) {

if (source[key] instanceof Array) {

if (source[key].length > 0) {

result[key] = typeof source[key] === 'object'

? deepCopy(source[key])

: source[key]

}

} else {

if (source[key]) {

result[key] = typeof source[key] === 'object'

? deepCopy(source[key])

: source[key]

}

}

}

return result

}