我有这个代码:
count = $content.find('.post').length;
for x in [1...count]
/*
prev_el_height += $("#content .post:nth-child(" + x + ")").height();
*/
prev_el_height += $content.find(".post:nth-child(" + x + ")").height();
Run Code Online (Sandbox Code Playgroud)
我希望这会变成
for (x = 1; x < count; x++) { prev_el ... }
Run Code Online (Sandbox Code Playgroud)
但它变成了这样:
for (x = 1; 1 <= count ? x < count : x > count; 1 <= count ? x++ : x--) {
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下原因吗?
编辑:如何获得我预期的语法输出?
Tre*_*ham 22
在CoffeeScript中,您需要使用by关键字来指定循环的步骤.在你的情况下:
for x in [1...count] by 1
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7050 次 |
| 最近记录: |