Home > @opennd/lib > setValueByPath
setValueByPath() function
使用字符串点操作获设置对象中属性, 中间不存在的属性值将被设为 {}
Signature:
typescript
export declare function setValueByPath(obj: any, path: string, value: any): any;Parameters
Parameter | Type | Description |
|---|---|---|
obj | any | |
path | string | |
value | any |
any
Example
setValueByPath(obj, 'a.b.c', 'value')