antd pro代碼有omitjs的用法,拿來研究
1、omitjs干什么用的
返回一個沒有列入排除key屬性的對象病涨。其中熬北,參數(shù)object為JSON格式的對象疙描,*keys表示多個需要排除掉的key屬性。
用法
import omit from 'omit.js';
const inputProps = omit(otherProps, ['onGetCaptcha', 'countDown']);
<Input {...customprops} {...inputProps} />
替代方法
const {onGetCaptcha, countDown, ...rest} = otherProps;
<Input {...customprops} {...inputProps} />
const abc = {a:12,b:23,c:34};
const {c,...rest} = abc;
console.log(abc);
console.log(rest);
2讶隐、omitjs源碼怎么寫的
import _extends from "babel-runtime/helpers/extends";
function omit(obj, fields) {
var shallowCopy = _extends({}, obj);
for (var i = 0; i < fields.length; i++) {
var key = fields[i];
delete shallowCopy[key];
}
return shallowCopy;
}
export default omit;