如何将消息导入到指令中

  • 本文关键字:指令 导入 消息 sass
  • 更新时间 :
  • 英文 :


我使用@warn很多,但我想将预写的消息导入到我的警告中,例如存储在另一个函数或文件中。

这可能吗?

我知道下面的方法是行不通的,但是你明白了…

@if $a == 'red' {
    color: red;
} @else if $a == 'blue' {
    color: blue;
} @else {
    @warn '@include error-msg_no-color-detected';
}

可以使用变量…

$msg: 'Something went wrong!';
@if ... {
    ...
} @else {
    @warn: '#{$msg}';
}

这允许我创建包含大量消息的_debug.scss文件。

@import 'config';
@import 'debug';
@import 'dark';
@import 'application';

_debug.scss:

@msg-1: 'Oops!';
@msg-2: 'No color defined. Check the config file.';

最新更新