在 LESS 的同一个选择器中使用 mixin?

Using mixin inside the same selector in LESS?

我正试图在 LESS 中实现这样的目标:

.a {
    // some properties
}

.b {
    .a {
        .a();
    }
}

它不起作用,因为它从最近的范围中获取 .a(),在本例中是 .b .a。我需要这个古怪的规则来覆盖 .a 的另一个上下文以使用默认的 .a 样式。

我可以在 LESS 中调用同一个选择器的 mixin 吗?或者也许有一些解决方法?

使用单独的 mixin class 并在非 inside-b 和 inside-b 情况下引用它。

要防止输出混入 class,请使用函数混入定义 syntax:

.a() {}

此外,mixins 可以在虚拟 id 中定义为 namespace,并且不应该也输出该 mixins。