draw里面的for循環(huán)為什么不用加{ }
? function draw(piece, cxt) {?
? ? ? ? ? ? cxt.beginPath();
? ? ? ? ? ? cxt.moveTo(piece.p[0].x, piece.p[0].y);
? ? ? ? ? ? for (var i = 1; i < piece.p.length; i++) {
? ? ? ? ? ? ? ? cxt.lineTo(piece.p[i].x, piece.p[i].y);
? ? ? ? ? ? ? ? cxt.closePath();
? ? ? ? ? ? ? ? cxt.fillStyle = piece.color;
? ? ? ? ? ? ? ? cxt.fill();
? ? ? ? ? ? }
? ? ? ? }
這個(gè)for循環(huán)為什么加了{(lán) }反而錯(cuò)啦?
2017-03-20
{}包裹的位置不對