0
var canvas = document.createElement('canvas'), canvasContext = canvas.getContext('2d');
canvas.width = image.width;
canvas.height = image.height;
canvas.id = ;
canvasContext.drawImage(image, 0, 0);
container.append(canvas);

我怎样才能给我所有生成的画布的唯一 ID

4

1 回答 1

0

你不能只添加一个计数器吗?:

var counter = 0;
...
canvas.id = 'something_' + counter;
...
counter++:

或者对你来说是独一无二的?

于 2013-04-14T21:51:01.603 回答