【问题标题】:How do I reference a bootstrap scss variable using @use?如何使用 @use 引用引导 scss 变量?
【发布时间】:2021-03-06 03:07:07
【问题描述】:

我的站点中有一个简单的组件样式表,我正在尝试引入$zindex-fixed 变量,但我的方法似乎有问题。任何帮助将不胜感激!

我的样式表如下:

@use "~bootstrap/scss/variables";

.playerBar {
  position: fixed;
  left: 0px;
  bottom: 0px;
  height: 90px;
  min-width: 620px;
  width: 100%;
  z-index: variables.$zindex-fixed;
  background: #1e1e1e;
}

我收到以下错误:

SassError: Undefined mixin.
    ╷
307 │ @include _assert-ascending($grid-breakpoints, "$grid-breakpoints");
    │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ╵
  node_modules/bootstrap/scss/_variables.scss 307:1  @use

这是使用 Bootstrap 5.0.0-beta1 和 sass 1.30.0。如果我可以提供更多信息来帮助诊断,请告诉我!

【问题讨论】:

  • 你在使用 Dart Sass 吗?
  • 是的,版本 1.30

标签: sass bootstrap-5


【解决方案1】:

Bootstrap v5中有no current plans支持sass模块系统。目前,解决方案是使用@import 而不是@use

@import "~bootstrap/scss/functions";
@import "~bootstrap/scss/variables";

.playerBar {
  position: fixed;
  left: 0px;
  bottom: 0px;
  height: 90px;
  min-width: 620px;
  width: 100%;
  z-index: $zindex-fixed;
  background: #1e1e1e;
}

【讨论】:

  • 主要是脱离 sass 团队不鼓励使用 @import 规则的免责声明:sass-lang.com/documentation/at-rules/import
  • 对,因为他们正在逐步淘汰它。
  • 我可能不擅长这个,但是每当我使用 (at)import 和 bootstrap 时,我都会在我的 webpacked 输出中得到一个精美的新 css 副本。进口越多,复制越多。 (at)use 是我发现的唯一方法。
猜你喜欢
  • 2021-05-07
  • 2021-06-04
  • 2018-03-28
  • 1970-01-01
  • 1970-01-01
  • 2019-07-23
  • 2021-07-07
  • 2014-10-07
相关资源
最近更新 更多