// 遍历生成的样式表,在 CSS 的原样式中进行全局替换
Object.keys(colors).forEach((key) => {
// cssText = cssText.replace(
// new RegExp('(:|\\s+)' + key, 'g'),
// '$1' + colors[key]
// )
const regex = new RegExp(`(--el-color-[\\w-]*${key}:)[^;]+`, 'g')
cssText = cssText.replace(regex, `$1${colors[key]};`)
})
改一下正则方法