我尝试将图像从本地文件上传到 CreateJS。代码是:
function draw() {
stage = new createjs.Stage('canvas');
var img = new Image(),
f = document.getElementById("uploadimage").files[0],
url = window.URL || window.webkitURL,
src = url.createObjectURL(f);
img.src = src;
img.onload = function() {
image = new createjs.Bitmap(this);
stage.addChild(image);
stage.update();
url.revokeObjectURL(src);
}
}
document.getElementById("uploadimage").addEventListener("change", draw, false);
但是选择文件后,图像不会显示在画布上。怎么了?