跳到主要内容

setWith()

function setWith(
object,
path,
value,
customFun): Record<string, any>;

Defined in: object/setWith.ts:14

这个方法类似 set 除了它接受一个 customFun 决定如何设置对象路径的值。 如果 fun 返回 undefined 将会有它的处理方法代替。 customFun 会传入3个参数:(nsValue, key, nsObject)

Parameters

ParameterType
objectRecord<string, any>
pathstring
valueany
customFun(currentValue, key, object) => any

Returns

Record<string, any>