1、教程、api
https://www.cnblogs.com/slongs/p/10298896.html
https://www.jianshu.com/p/5dfa9f0bb11e
2、创建封装方法的文件:
路径:src→utils→index.js
index.js
export function objClone(jsonObj) {
let buf
if (jsonObj instanceof Array) {
buf = []
let i = jsonObj.length
while (i--) {
buf[i] = objClone(jsonObj[i])
}
return buf
} else if (jsonObj instanceof Object) {
buf = {}
for (let k in jsonObj) {
buf[k] = objClone(jsonObj[k])
}
return buf
} else {
return jsonObj
}
}
子组件引入使用
import * as utils from "@/utils/index.js";
utils.objClone(objext)