当 mixin 保存在单独的文件夹中时,Sass 编译器会抛出“未定义的 mixin"错误 [英] Sass compiler throws 'undefined mixin' error when mixins are kept in seperate folder
问题描述
这是我网站结构的截图.
Here is the screenshot of my website structure.
在我的 mixins 文件中,我已经创建了所有必要的 sass mixin.
In my mixins file, I have created all the necessary sass mixins.
我为边界半径创建了这个mixin:
I have created this mixin for border radius:
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
-o-border-radius: $radius;
border-radius: $radius;
}
现在,当我尝试将它用于模块文件夹中 _button.scss 中的按钮类时,出现未定义变量错误.而当我在 _button.scss 文件本身中使用相同的 mixin 时,我没有收到任何错误.
Now when I try to use this for my button class in _button.scss in modules folder , I get undefined variable error. Whereas when I use the same mixin in the _button.scss file itself, I don't get any error.
在我的 _button.scss 文件中,我包含了如下所示的 mixin
in my _button.scss file i have included the mixin as under
button{
background-color: $theme-color;
border: 0px solid;
padding: 0.7rem 3rem;
@include border-radius(2rem);
}
究竟是什么问题.我想将所有的 mixin 保存在一个单独的文件中,以保持结构整洁.
What is the issue exactly. I want to keep all my mixins in a seperate file to keep the structure neat.
推荐答案
you must include the mixin with @include or @import
you have to include the mixin with @include or @import
http://sass-lang.com/documentation/file.SASS_REFERENCE.html#include_a_mixin
这篇关于当 mixin 保存在单独的文件夹中时,Sass 编译器会抛出“未定义的 mixin"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!