LESS class name string interpolation not working

你说的曾经没有我的故事 提交于 2019-12-29 09:41:49

问题


I am currently translating my grid into LESS, but I can't seem to figure out string interpolation.

Here's helper class that is supposed to generate all my columns:

.createColumns (@colNumber+1) {}

.createColumns (@index) when (@index < @colNumber) {
    (~".col@{index}") {
         width: @baseWidth * @index;
    }

    .createColumns (@index + 1);
}

.createColumns (01);

Problem is, I get error that says something is wrong with this part (~".col@{index}").

Here's the error message:

ParseError: Unrecognised input
in grid.css on line 17, column 4:
16    .createColumns (@index) when (@index < @colNumber) {
17        (~".col@{index}") {
18            width: @baseWidth * @index;

I have checked several examples and all use same syntax, so I'm not sure what I'm missing. This was also one of my tries that resulted in an error:

.createColumns (@index) when (@index < @colNumber) {
    @class : "col"@index;
    .(@class) {
        width: @baseWidth * @index;
    }
.createColumns (@index + 1);
}

回答1:


Escaped selector interpolation is deprecated in 1.4.x, use

.col@{index} {
     width: @baseWidth * @index;
}

instead.



来源:https://stackoverflow.com/questions/18675359/less-class-name-string-interpolation-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!