Uncaught TypeError: Cannot read property 'width' of null at Object._rebuildQuads_base (CCScale9Sprite.js:213) at TheClass._rebuildQuads (CCScale9Sprite.js:1371) at 208.cc.Scale9Sprite.CanvasRenderCmd.208.proto.transform (CCScale9SpriteCanvasRenderCmd.js:40) at 208.cc.Scale9Sprite.CanvasRenderCmd._syncStatus (CCSGNodeCanvasRenderCmd.js:506) at 208.cc.Scale9Sprite.CanvasRenderCmd.visit (CCSGNodeCanvasRenderCmd.js:352) at TheClass.visit (CCSGNode.js:1865) at ccsg_Node.visit (CCSGNode.js:1876) at ccsg_Node.visit (CCSGNode.js:1885) at ccsg_Node.visit (CCSGNode.js:1885) at ccsg_Node.visit (CCSGNode.js:1885)
为scrollView添加元素 的时候,第一次正常,第二次以后就一直报这个错误,有大神知道怎么解决么?
有知道的大神,可以帮忙解决一下么?
Cannot read property ‘width’ of null 没有width
var scale9QuadGenerator = {
x: new Array(4),
y: new Array(4),
_rebuildQuads_base: function (sprite, spriteFrame, contentSize, insetLeft, insetRight, insetTop, insetBottom) {
//build vertices
var vertices = sprite._vertices;
var wt = sprite._renderCmd._worldTransform;
var leftWidth, centerWidth, rightWidth;
var topHeight, centerHeight, bottomHeight;
var rect = spriteFrame._rect;
leftWidth = insetLeft;
rightWidth = insetRight;
centerWidth = rect.width - leftWidth - rightWidth;
topHeight = insetTop;
bottomHeight = insetBottom;
centerHeight = rect.height - topHeight - bottomHeight;
var preferSize = contentSize;
var sizableWidth = preferSize.width - leftWidth - rightWidth;
var sizableHeight = preferSize.height - topHeight - bottomHeight;
var xScale = preferSize.width / (leftWidth + rightWidth);
var yScale = preferSize.height / (topHeight + bottomHeight);
xScale = (isNaN(xScale) || xScale > 1) ? 1 : xScale;
yScale = (isNaN(yScale) || yScale > 1) ? 1 : yScale;
sizableWidth = sizableWidth < 0 ? 0 : sizableWidth;
sizableHeight = sizableHeight < 0 ? 0 : sizableHeight;
var x = this.x;
var y = this.y;
x[0] = 0;
x[1] = leftWidth * xScale;
x[2] = x[1] + sizableWidth;
x[3] = preferSize.width;
y[0] = 0;
y[1] = bottomHeight * yScale;
y[2] = y[1] + sizableHeight;
y[3] = preferSize.height;
if (vertices.length < 32) {
dataPool.put(vertices);
vertices = dataPool.get(32) || new Float32Array(32);
sprite._vertices = vertices;
}
var offset = 0, row, col;
if (webgl) {
for (row = 0; row < 4; row++) {
for (col = 0; col < 4; col++) {
vertices[offset] = x[col] * wt.a + y[row] * wt.c + wt.tx;
vertices[offset+1] = x[col] * wt.b + y[row] * wt.d + wt.ty;
offset += 2;
}
}
}
else {
for (row = 0; row < 4; row++) {
for (col = 0; col < 4; col++) {
vertices[offset] = x[col];
vertices[offset+1] = y[row];
offset += 2;
}
}
}
cornerId[0] = 0; // bl
cornerId[1] = 6; // br
cornerId[2] = 24; // tl
cornerId[3] = 30; // tr
//build uvs
if (sprite._uvsDirty) {
this._calculateUVs(sprite, spriteFrame, insetLeft, insetRight, insetTop, insetBottom);
}
},
就这个方法报的错
请问是什么版本?看起来像是资源没有加载成功
谢谢,已经搞定了
您好,请问这个问题是怎么搞定的?
我也遇到了一样的问题,一时找不到原因
您好 请问 是如何解决的。