zgg-ui
Version:
2.0.1 正式版本 基于 Vue 3、UniApp 和 TypeScript 开发的多端适配移动端 UI 组件库,旨在提供丰富的组件集合,帮助开发者快速构建多端响应式的移动应用界面
25 lines (22 loc) • 653 B
text/typescript
import { get, set } from '../../libs/lodash'
import type { Entries } from 'type-fest'
import type { Arrayable } from '../../libs/zType'
export { hasOwn } from '@vue/shared'
export const keysOf = <T extends object>(arr: T) =>
Object.keys(arr) as Array<keyof T>
export const entriesOf = <T extends object>(arr: T) =>
Object.entries(arr) as Entries<T>
export const getProp = <T = any>(
obj: Record<string, any>,
path: Arrayable<string>,
defaultValue?: any
): { value: T } => {
return {
get value() {
return get(obj, path, defaultValue)
},
set value(val: any) {
set(obj, path, val)
},
}
}