cloneDeep 克隆
bash
import { cloneDeep,reduce } from 'lodash';
const b = {c:1}
const a = cloneDeep(b)
debounce 防抖
bash
import { debounce } from 'lodash';
debounce(() => {
}, 300, { trailing: true })()
omit方法删除指定属性,返回一个新的对象
bash
import { omit } from 'lodash';
var obj= { 'a': 1, 'b': '2', 'c': 3 };
//参数一:obj对象
//参数二:需删除的属性
var result = omit(obj, ['a', 'b']);
var resule = omit(obj, function(value, key) {
return key === 'a' || key === 'b';
})
//结果{c:3}
isEqual判断两个对象属性值是否相等
bash
const [newData, setNewData] = useState<any>({});
useEffect(() => {
if (!isEqual(newData, data)) {
setNewData(data)
}
}, [data]);