/** * 深度遍历对象 * @author 韦胜健 * @date 2022.5.2 12:01 */ export function deepIterateObject(obj: any, handler: (key: string, value: any, accessPath: string[]) => void, nowAccessPath: string[] = []) { Object.entries(obj).forEach(([key, value]) => { const ap = [...nowAccessPath, key]; handler(key, value, ap); if (Array.isArray(value) || typeof value === "object") { deepIterateObject(value, handler, ap); } }); }