gpt4 book ai didi

css - 我可以跨 SCSS 文件使用变量吗?

转载 作者:行者123 更新时间:2023-11-28 19:13:40 24 4
gpt4 key购买 nike

我使用了不同的“SCSS 变量文件”( Bootstrap 变量、公司变量、元素变量),因此很容易在其他元素中重复使用它们。但似乎我不能跨文件使用变量。

例子:

  • company-variables.scss 我声明了 $white: #fff;
  • project-variables.scss 中,我想像这样重用上面的变量 $body-color: darken($white, 20%);
  • 我收到以下错误: undefined variable :“$white”。 $body-color: darken($white, 20%);

我这样加载我的文件:

@import "bootstrap-variables";
@import "company-variables";
@import "project-variables";

路径是正确的。

我是 SCSS 的新手。知道我做错了什么或者这是不可能的/不是要走的路吗?

最佳答案

如果你想使用它,你应该导入@import "company-variables";进入@import“元素变量”;

或者像这样使用 Bootstrap 中的默认白色:变暗(主题颜色(“白色”),20%);

关于css - 我可以跨 SCSS 文件使用变量吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58836042/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com