使用less时循环动态导入

时间:2016-04-29 02:34:04

标签: css less

theme.less:

@theme: blue, red;
.createTheme(@i:1) when (@i <= length(@theme)) {
  @name: extract(@theme, @i);
  @import "@{name}.less";
  .@{name} {
    background: @footer-bg;
}
.createTheme()

blue.less:

@footer-bg:blue;

red.less:

@footer-bg:red;

我收到了错误:

Module build failed: Recursive variable definition for @i
 @ D:\app\theme.less (line 10, column 0)
 near lines:

   .createTheme();

解决这个问题的任何解决方案?

0 个答案:

没有答案