less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17.02k stars 3.41k forks source link

floor函数在使用+-*/符号时..新版本需要使用一个()包裹住算式才可以,老版本的不需要...英语不好,中文将就看一下吧! #3596

Closed zc-tired closed 3 years ago

zc-tired commented 3 years ago

这是改好之后的

@menuWidth: 55px;
@menuHeight: 158px;
@menuTop: 0px;
@menuMargin: 37px;
@menuNum: 8;
.generate-main-menu1(@n, @i: 1) when (@i =< @n) {
    #mainMenu@{i} {
      @num: floor(((@i - 1) / @menuNum));
      .absolute((@menuWidth + @menuMargin) * ((@i - 1) - @num * @menuNum),
                @menuTop + (@menuHeight + @menuMargin) * @num);
    }
    .generate-main-menu1(@n, (@i + 1));
  }
  .generate-main-menu1(4);

原先的写法是

@menuWidth: 55px;
@menuHeight: 158px;
@menuTop: 0px;
@menuMargin: 37px;
@menuNum: 8;
.generate-main-menu1(@n, @i: 1) when (@i =< @n) {
    #mainMenu@{i} {
      @num: floor((@i - 1) / @menuNum);
      .absolute((@menuWidth + @menuMargin) * ((@i - 1) - @num * @menuNum),
                @menuTop + (@menuHeight + @menuMargin) * @num);
    }
    .generate-main-menu1(@n, (@i + 1));
  }
  .generate-main-menu1(4);

用老的写法新版本less编译就会报异常SyntaxError: Error evaluating function floor: argument must be a number

matthew-dean commented 3 years ago

Issues should be in English, thank you.

Zauberbutter commented 3 years ago

I think @zcsoniubi's issue here is, that since 4.0.0 the division operator needs additional parenthesis. You can read more about that here: https://lesscss.org/usage/#less-options-math