简体   繁体   English

在mixin上使用变量或在Less.js中扩展

[英]use variables on mixin or extend in Less.js

Using variable on mixin or extend in Less.js as follow will throw error. mixin上使用变量或在Less.js extendLess.js ,将引发错误。

@bar : bar;

.@{bar} {
  background: yellow;
}

// ParseError: Missing closing ')'
.foo {
  .@{bar}(); 
}

// Not work
.jam {
  &:extend(.@{bar});
}

Has Less.js a proper syntax to call mixin with variables? Less.js是否具有正确的语法来调用带有变量的mixin

You are trying to call a mixin using selector interpolation, which is not possible . 您正在尝试使用选择器插值调用mixin, 这是不可能的

As for extend, Less documentation states it clearly : 至于扩展,更少的文档明确指出

Extend is NOT able to match selectors with variables. Extend无法将选择器与变量匹配。 If selector contains variable, extend will ignore it. 如果选择器包含变量,则extend将忽略它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM