import { normalizeKeyPath } from "./normalizeKeyPath" /** * 根据键名路径获取对象值 * * @param object 对象 * @param path 键名路径 * @return {any} */ export function getObjectValue(object: object, path: string | string[]) { let keyPath = normalizeKeyPath(path) let cursor: any = object keyPath.every((key, index) => { cursor = cursor[key] if (cursor == undefined) return false return true }) return cursor }