【发布时间】:2021-07-28 21:40:47
【问题描述】:
我尝试在 mixin 中获取变量,但在使用守卫时它不起作用。我肯定错过了规则中的某些内容。请参考以下代码sn-p。
@list: #000, #fff;
div {
.custom-colors(@list, 0%, 20%, true);
color: @gradient; // here I need the output
}
.custom-colors(@value, @light, @dark, @lightdark){
& when (@lightdark = true){
@gradient: lighten(extract(@value, 1), @light), darken(extract(@value, 2), @dark);
}
& when (@lightdark = false){
@gradient: darken(extract(@value, 1), @dark), lighten(extract(@value, 2), @light);
}
}
执行上述代码时出现此错误:
如果我删除了保护条件,我可以在 less mixin 中获取变量,如下所示。
div {
color: #000000, #cccccc;
}
我错过了什么?
【问题讨论】: