Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

antd 使用 antd-theme-generator 更换主题无法更换函数写的less变量颜色

antd 中 @primary-1 的颜色定义如下

@primary-1: color(~`colorPalette('@{primary-color}', 1) `);

我现在希望更换它的颜色。
antd-theme-generator 配置如下

const themeVariables = ['@primary-color', '@primary-1']
const options = {
  stylesDir: path.join(__dirname, './src/styles'),
  antDir: path.join(__dirname, './node_modules/antd'),
  varFile: path.join(__dirname, './src/styles/vars.less'),
  mainLessFile: path.join(__dirname, './src/styles/main.less'),
  themeVariables: themeVariables,
  indexFileName: 'index.html',
  outputFilePath: path.join(__dirname, './public/color.less'),
  customColorRegexArray: [/^color(.*)$/]
}

generateTheme(options).then(less => {
  console.log('Theme generated successfully');
})
  .catch(error => {
    console.log('Error', error);
  })

文档提示需要改配置中的customColorRegexArray,我已修改。
但是之后我用

window.less.modifyVars({
  '@primary-color': '#eee',
  '@primary-1': '#111'
})

修改主题色,@primary-color 生效了但是 @primary-1 没有生效。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

antd-theme 换成这个就可以了


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...