Variable @primary-color-hover is undefined

2024-08-20 14:41:59

最近在处理公司老项目时,遇到这个问题。

这个问题产生原因:依赖项 @ant-design/pro-xxx 需要的基础样式是从 antd 引入的,但是 antd 的基础变量里面把这个删除了,所以会报这个错误。

解决方案

1. 固定 @ant-design/pro-xxx 版本

项目中报错依赖信息

"dependencies": {
    ...
    "@ant-design/pro-descriptions": "^1.9.0",
    "@ant-design/pro-form": "^1.43.0",
    "@ant-design/pro-layout": "^6.26.0",
    "@ant-design/pro-table": "^2.56.0",
    "@umijs/route-utils": "^2.0.3",
    "antd": "4.16.13",
}

固定 @ant-design/pro-xxx 版本:

"dependencies": {
    ...
    "@ant-design/pro-descriptions": "1.9.0",
    "@ant-design/pro-form": "1.43.0",
    "@ant-design/pro-layout": "6.26.0",
    "@ant-design/pro-table": "2.56.0",
    "@umijs/route-utils": "2.0.3",
    "antd": "4.16.13",
}

2. 升级 antd 版本

项目之前版本是 4.16.13

"dependencies": {
    ...
    "antd": "4.16.13",
}

升级后版本:4.20.0

"dependencies": {
    ...
    "antd": "4.20.0",
}

3. 定义 primary-color-hover 变量值

在config/config.ts中设置一个less变量:

theme: {
    ...
    "primary-color-hover": defaultSettings.primaryColor,
}, 

目录

相关推荐
关于调用微软Bing API推送链接时,报:errorcode 3 message ERROR!!! InvalidApiKey如何调用百度和微软必应链接收录APIMac安装nvm时,各种问题总结react-app-rewired中如何设置ant-design主题,以及不生效问题Ant-Design-Vue Form 中,对于多选下拉表表单时,重置时,表单未正确展示