Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 使用Grunt+;时的循环错误更少;引导程序3_Css_Loops_Twitter Bootstrap 3_Gruntjs_Less - Fatal编程技术网

Css 使用Grunt+;时的循环错误更少;引导程序3

Css 使用Grunt+;时的循环错误更少;引导程序3,css,loops,twitter-bootstrap-3,gruntjs,less,Css,Loops,Twitter Bootstrap 3,Gruntjs,Less,这是我的循环: @loop-start: 1; @loop-end: 20; .loop(@n, @i) when (@n =< @loop-end) { .testi-square:nth-of-type(@{n}) {order: (@i);} .testi-square:nth-of-type(@{n + 1}) {order: (@i + 1);} .testi-square:nth-of-type(@{n + 2}) {order: (@i + 2);} .lo

这是我的循环:

@loop-start: 1;
@loop-end: 20;
.loop(@n, @i) when (@n =< @loop-end) {
  .testi-square:nth-of-type(@{n}) {order: (@i);}
  .testi-square:nth-of-type(@{n + 1}) {order: (@i + 1);}
  .testi-square:nth-of-type(@{n + 2}) {order: (@i + 2);}

  .loop((@n + 3), (@i + 6)); // next iteration
}
.loop(@loop-start, @loop-start); // launch the loop

我正在使用最新的引导创建我的主题。在过去的6个月里,我一直在使用它,没有任何问题,我怀疑LESS的版本太旧了。不确定如何解决这个问题,这似乎是一个语法问题,但不确定。整天盯着看,搜索互联网,但没有骰子。

错误是因为以下几行:

.testi square:n类型(@{n+1}){顺序:(@i+1);}
.testi square:n型(@{n+2}){阶:(@i+2);}
当编译器遇到
@{n+1}
时,它将查找名为
n+1
的变量。您没有任何名为
n+1
的此类变量(而且它的语法也无效)。因此,它将导致编译错误。解决方法是使用如下内容:

@循环开始:1;
@环端:20;
.loop(@n,@i)何时(@n=<@loop end){
.testi square:n型(@{n}){阶:(@i);}
@温度:@n+1;
.testi square:nth类型(@{temp}){顺序:(@i+1);}
@temp2:@n+2;
.testi square:nth类型(@{temp2}){顺序:(@i+2);}
.loop((@n+3),(@i+6));//下一次迭代
}
.loop(@loop start,@loop start);//启动循环

正如seven Phase max在其评论中所述,我们不能在选择器插值中使用表达式、函数调用等。只允许变量。

n个类型(@{n+1})
-这不是有效的更少的代码。使用选择器插值不能使用表达式或其他任何东西(函数调用等),只有纯变量(如
@{n}
有效,
@{n+1}
无效。抱歉@seven-phases-max.在看到您的评论之前发布了答案。我认为你应该把你的评论也作为一个答案。
Running "less:compileThemeWeb" (less) task
ParseError: Missing closing ')' in less/theme-web.less on line 3630, column 29:
3629   .testi-square:nth-of-type(@{n}) {order: (@i);}
3630   .testi-square:nth-of-type(@{n + 1}) {order: (@i + 1);}
3631   .testi-square:nth-of-type(@{n + 2}) {order: (@i + 2);}
Warning: Error compiling less/theme-web.less Use --force to continue.

Aborted due to warnings.