减少关闭}

时间:2015-09-30 06:08:57

标签: visual-studio-2013 less

我有以下代码,只有我的Less文件中的代码。

@iterations: 100;
.width-loop (@i) when (@i > -1) 
{
     (~".w@{i}") 
     {
        width: ~"@{i}%  !important";
     }
    .width-loop(@i - 1);
}
.width-loop(@iterations);

结果是这样的。

.w100 {width 100% !important; }
.w99 {width 99% !important; }
...... 

但是,当我构建项目时,我的错误窗口会弹出此错误。

Less: Missing closing '}'

我错过了哪里}?弹出的错误窗口最令人分心。

当我在浏览器中查看输出时,样式类列表正确。

1 个答案:

答案 0 :(得分:3)

您正在调用该函数错误。这样做:

@iterations: 100;
.width-loop (@i) when (@i > -1) 
{
     .w@{i}
     {
        width: ~"@{i}%  !important";
     }
    .width-loop(@i - 1);
}

.width-loop(@iterations);