当LESS变量值转换为字符串时删除空格
问题描述:
下面是示例较少的混合代码
Below is example less mixin code
.mixin(@option) {
.set(@options) when (@options = a){
@type: linear;
}
.set(@option);
background: -webkit-~'@{type}'-gradient(...);
}
输出
background: -webkit- linear -gradient(...);
如何删除 linear
周围的空间?
答
Less不支持在值语句中通过变量插值进行就地串联.为此,您需要一个临时变量(在这种情况下,需要一个辅助变量来处理parens),例如:
Less does not support an inplace concatenation via variable interpolation in value statements. You need a temporary variable for this (+ an auxiliary variable in this particular case to handle parens), e.g.:
@end-func: ~')';
div {
@func: ~'-webkit-@{type}-gradient(';
background: @func ... @end-func;
}