0

好吧,我想在我的 js 代码中使用一些 css 变量。

这是我的 .css 文件和 .js 代码的一部分:

const root = document.querySelector(":root");
const msgColor = getComputedStyle(root).getPropertyValue("--msg-color");
console.log(msgColor);
:root {
  --msg-color: crimson;
  --msg-text: floralwhite;
}

问题是,在 chrome、safari 和新 Edge 中,我的常量中的颜色值是正确的,但在 Firefox 中,它不起作用。

有任何想法吗?谢谢。

4

1 回答 1

0

好像是firefox的版本。它是 68.xx 现在与 77.0.1 工作正常。

于 2020-06-17T09:41:29.623 回答