Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k 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 Answer

0 votes
by (71.8m points)

antd-theme 换成这个就可以了


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...