Sass错误:没有名为“math”的模块。

154

我在Vue应用程序中使用math SASS库时遇到了问题。它使用Dart Sass和sass-loader进行编译。Dart Sass版本为1.26.3,因此数学模块应该可以正常工作。

Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: There is no module with the namespace "math".

@for $i from 2 through 10 
    &:nth-child(#{$i}) { transition-duration: 300ms + $i * 50ms - 400ms * math.floor($i / 8); }
                                                                          ^^^^^^^^^^^^^^^^^^
}
2个回答

373

明白了,我需要添加

@use 'sass:math';

在文件顶部。


19
为什么这个内容没有直接记录在https://sass-lang.com/documentation/modules/math中?非常感谢! - denns
1
@denns 公平地说,它在以下文档中有记录:https://sass-lang.com/documentation/modules - xorinzor
是的,那就是我找到它的地方,但最初我进入了示例部分,由于这个问题,示例无法正常工作。 - denns

13

1
这对于试图修复Vue组件中的scss的人来说是行不通的。 - M. Gara

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接