handle-object-empty
v1.0.1
Published
处理对象中的空值
Downloads
2
Readme
项目简介
处理对象的属性值为空的情况
安装
yarn add handle-object-empty --save
或
npm install handle-object-empty --save
使用
import handleObjectEmpty from "handle-object-empty";
handleObjectEmpty({
a: 1,
b: "",
});
// {a: 1, b: undefined}
请求API: handleObjectEmpty(object[,config])
config说明
key|说明|默认值 --|:--:|--: defaultShowValue | 对空值属性设置默认值 | undefined deleteKey | 对空值的属性,是否删除该属性 | false propsDefaultValue | 可以对特定的属性设置默认值 | 无
注意:
- deleteKey的优先级最高,当设置为true时,其他配置都不会生效。
- 当在propsDefaultValue下配置了对应属性的默认值时,就不会采用defaultShowValue的值