deepClone.js
export function deepCopy(obj) {
if (obj === null || typeof obj !== 'object') {
return obj;
}
if (Array.isArray(obj)) {
return obj.map(deepCopy);
}
const newObj = {};
for (let key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
newObj[key] = deepCopy(obj[key]);
}
}
return newObj;
}
vue文件中使用
import { deepCopy } from '../components/deepCloen.js';
resetName.value = deepCopy(rightClickData.title)