综合编程

Set the name of the variable with a variable in MINUS mode

微信扫一扫,分享到朋友圈

Set the name of the variable with a variable in MINUS mode
0

Can someone please explain why this code doesn’t work:

@red-1:#ff0000;
@red-2:#990000;
@blue-1:#000ff;
@blue-2:#00099;

.setTheme(@theme){
  @color-1:~"@{@{theme}-1}";
  @color-2:fade(~"@{@{theme}-2}", 10%); //doesn't work
  [email protected]{theme} .button{
    background:@color-1;
    color:@color-2;
  }
}

.setTheme(~"red");

Thanks;

It is a Bug

Color functions have an issue with respect to this that has been submitted
.

Workaround

Don’t try to do both calls in one string. Set the variable value to your inner variables. Then when you use them, use the @@
syntax directly. Like this:

@red-1:#ff0000;
@red-2:#990000;
@blue-1:#000ff;
@blue-2:#00099;

.setTheme(@theme){
  @color-1:~"@{theme}-1";
  @color-2:~"@{theme}-2";
  @color-2faded: fade(@@color-2, 10%);
  [email protected]{theme} .button{
    background:@@color-1;
    color:@color-2faded;
  }
}

.setTheme(~"red");

Or without the extra variable:

.setTheme(@theme){
  @color-1:~"@{theme}-1";
  @color-2:~"@{theme}-2";
  [email protected]{theme} .button{
    background:@@color-1;
    color: fade(@@color-2, 10%);
  }
}

阅读原文...


Hello, buddy!

智能世界正在加速到来,我们离真正的人工智能(AI)还有多远

上一篇

Spring依赖注入原理分析

下一篇

您也可能喜欢

评论已经被关闭。

插入图片
Set the name of the variable with a variable in MINUS mode

长按储存图像,分享给朋友