问答

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

作者:admin 2021-08-21 我要评论

antd 中 @primary-1 的颜色定义如下 @primary-1: color(~\`colorPalette('@{primary-color}', 1) \`); 我现在希望更换它的颜色。 antd-theme-generator 配置如下...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

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 没有生效。

###

antd-theme 换成这个就可以了

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • 使用箭头函数return数据不能实现

    使用箭头函数return数据不能实现

  • 个人小程序号能接入小程序3D地图吗?

    个人小程序号能接入小程序3D地图吗?

  • vue 移动端项目中,使用了better-scrol

    vue 移动端项目中,使用了better-scrol

  • css如何做出区域平均划分为四列

    css如何做出区域平均划分为四列

腾讯云代理商
海外云服务器