我想在度量中创建几个节拍(使用SVG),并将它们放在一起。我有点困惑如何跟踪underscore.js中的迭代器在函数中使用。_Underscore中的迭代器计数
以下是我有:
_.each(beats, function(beat) {
// create a beatview
var measurePassingToBeatViewParamaters = {
beatXLocation: beatXLocation
// i want this to be something like beatXLocation: beatXLocation * beatCountIterator
};
new beatView(measurePassingToBeatViewParamaters); //backbone View
// then somewhere increase the beatCountIterator ++;
}, this); //this is a measure
您是否已经检出[docs](http://underscorejs.org/#each)? – Bergi 2013-04-04 14:31:47
是的,它说迭代器(在我的情况下是一个函数)用三个参数(元素,索引,列表)调用。我想索引参数,但他们给出的例子并没有显示我如何访问这个参数。我尝试命名,将函数声明为“变量”,然后将其称为“variable.index”,但不成功。 – 2013-04-04 14:34:41