简体   繁体   English

如何将 bootstrap-vue 主题颜色设置为 css 变量?

[英]How can I set bootstrap-vue theme colors to css variables?

I'm using bootstrap-vue and would like to be able to override the theme colors dynamically at runtime (after compiling the scss).我正在使用 bootstrap-vue 并且希望能够在运行时动态覆盖主题颜色(在编译 scss 之后)。 To do this I'm following this guide: https://bootstrap-vue.org/docs/reference/theming to set the bootstrap theme colors to a css variable:为此,我遵循本指南: https : //bootstrap-vue.org/docs/reference/theming将引导程序主题颜色设置为 css 变量:

$theme-colors: (
  "info": var(--info)
);

@import "node_modules/bootstrap/scss/bootstrap";

However, when I compile the scss I get the following error:但是,当我编译 scss 时,出现以下错误:

SassError: argument `$color-2` of `mix($color-1, $color-2, $weight: 50%)` must be a color
on line 106 of node_modules/bootstrap/scss/_functions.scss, in function `mix`

Is it possible to inject css variables like I want?是否可以像我想要的那样注入 css 变量? If so how?如果是这样怎么办?

It looks like I've run into a known limitation to bootstrap's scss.看起来我遇到了引导程序 scss 的已知限制。 This blog outlines a workaround by overriding bootstraps functions: Changing Bootstrap Theme at Runtime with CSS Variables此博客概述了通过覆盖引导程序函数的解决方法: 在运行时使用 CSS 变量更改引导程序主题

However it reportedly doesn't work with IE 11.但是据报道它不适用于 IE 11。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM