gpt4 book ai didi

css - SASS:使用@extend 时为 'Undefined variable'

转载 作者:行者123 更新时间:2023-11-28 16:36:06 27 4
gpt4 key购买 nike

我想为我的 android 和 ios 样式表使用一些通用样式。所以我将通用样式放在一个文件中。

_base.scss

%base {
color: $baseColor;
}

现在我想将它用于两个样式表:

main-ios.scss:

@import 'base';

$baseColor: #fff;
main {
@extend %base;
}

主-android.scss:

@import 'base';

$baseColor: #000;
main {
@extend %base;
}

我希望它编译为(对于 android):

main {
color: #000;
}

但是,我得到了

Syntax error: Undefined variable: "$baseColor".

无论如何我可以解决这个问题吗?

更新:

我想通了,首先在主文件中定义变量而不是导入!

最佳答案

您是否尝试过在导入声明之前定义您的变量?

$baseColor: #000;

@import 'base';

main {
@extend %base;
}

关于css - SASS:使用@extend 时为 'Undefined variable',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28267368/

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