场景
例如,我们要修改antd组件库的buttun组件
修改
找到node_modules里面的antd,路径:node_modules -> antd -> es -> button -> button.js
- var buttonNode = /*#__PURE__*/React.createElement("button", _extends({}, rest, {\
+ var buttonNode = /*#__PURE__*/React.createElement("span", _extends({}, rest, {\
type: htmlType,\
className: classes,\
onClick: handleClick,\
ref: buttonRef\
}), iconNode, kids)
修改npm包
- yarn add antd patch-package postinstall-postinstall -D
- 在package.json文件script中添加脚本命令
"scripts": {\
+ "postinstall": "patch-package"\
}
3.yarn patch-package antd