当使用React启动AntDesignpro-field工程时遇到尝试导入错误,因为AntDesign版本(4.24.12)不包含ColorPickerV5。解决方法包括移除对ColorPickerV5的引用并引入V4版本,以及在需要的地方替换V5。 react启动工程时提示,
./node_modules/@ant-design/pro-field/es/components/ColorPicker/index.js
Attempted import error: 'ColorPicker' is not exported from 'antd' (imported as 'ColorPickerV5')
解决办法: 去到…/node_modules/@ant-design/pro-field/es/components/ColorPicker/index.js文件 1、去掉从antd引用ColorPickerV5
import { ColorPicker as ColorPickerV5, ConfigProvider, version } from 'antd';
// 改成
import { ConfigProvider, version } from 'antd';
2.替换ColorPickerV5为ColorPickerV4
function getColorPicker() {
var old = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
if ((typeof old === 'undefined' || old === false) && IsIt_Render_V5()) {
return ColorPickerV4; // 将这个ColorPickerV5改成ColorPickerV4
}
return ColorPickerV4;