所以我试图根据从 php-less 编译器传入的变量覆盖一些“全局”变量。
我不确定我是否做错了什么,或者是否由于范围而不可能?
编辑:在这种情况下,我试图让身体的背景变成红色。
无外部
// From external less stylesheet that I can't/don't want to modify
@myColour: blue;
body {
background: @myColour; // always blue
}
我的.less
@import "external.less"
// My styles
.setResponsive(@responsive) when (@responsive = on) {
@myColour: green;
}
.setResponsive(@responsive) when (@responsive = off) {
@myColour: red;
}
@responsiveState: off; // actually being set from compiler
.setResponsive(@responsiveState);
div {
.setResponsive(@responsiveState);
background: @myColour; // red
}