[]源码List的一次代码错误

下面加粗的两行,原意应该是利用删除的item,但是看定义arr上面定义的是局部变量。
__proto._createItems = function (startY, numX, numY) {
var box = this._content;
var cell = this._getOneCell();
var cellWidth = cell.width + this._spaceX;
var cellHeight = cell.height + this._spaceY;
if (this.cacheContent) {
var cacheBox = new Box();
cacheBox.cacheAsBitmap = true;
cacheBox.pos((this._isVertical ? 0 : startY) * cellWidth, (this._isVertical ? startY : 0) * cellHeight);
this._content.addChild(cacheBox);
this._content.optimizeScrollRect = true;
box = cacheBox;
} else {
[b] var arr = [];
[/b] for (var i = this._cells.length - 1; i > -1; i--) {
var item = this._cells[i];
item.removeSelf();
arr.push(item);
}
this._cells.length = 0;
}
for (var k = startY; k < numY; k++) {
for (var l = 0; l < numX; l++) {
[b][i] if (arr && arr.length) {
[/i][/b] cell = arr.pop();
} else {
cell = this.createItem();
}
cell.x = (this._isVertical ? l : k) * cellWidth - box.x;
cell.y = (this._isVertical ? k : l) * cellHeight - box.y;
cell.name = "item" + (k * numX + l);
box.addChild(cell);
this.addCell(cell);
}
}
}
已邀请:

w1114367261

赞同来自:

这个不是bug哦

要回复问题请先

商务合作
商务合作