Skip to content

umi3 升级到 umi4,Antd 4 如何自定义样式? #12929

Closed Answered by zzj0231
zzj0231 asked this question in Q&A
Discussion options

You must be logged in to vote

将项目从 umi3 升级到 umi4, 自定义 Antd4 主题失效了,有什么解决办法吗 ?

export default defineConfig({ antd: { dark: false, compact: false }, theme, // 定义的项目主题, 升级后查看文档只对 antd5 有效 })

umi4 内置的 antd4, 但配置文件的样式配置都是针对 antd5 的

已经解决,配置中的 lessLoader 的 modifyVars 默认是 useConfig.theme,但我项目给这个变量设置了其他值,所以在Umi4设置Antd4主题需要下面这么配置

lessLoader: { modifyVars: { ...antd4Theme, ...otherValue }, math: 'always' },

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zzj0231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant