ivue-material-plus
Version:
A high quality UI components Library with Vue.js
19 lines (16 loc) • 377 B
text/typescript
import { get, set } from 'lodash-unified';
export type Arrayable<T> = T | 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);
},
};
};