我从JSON对象加载画布并调用toDataURL
但我需要一个回调,它将在加载画布后执行,因为如果画布上有图像,toDataURL
函数会返回一个空白页面,因为它是在加载图像之前调用。
canvas.loadFromJSON(json);
// I need an event handler here which will be executed after canvas is loaded
var dataURL = canvas.toDataURL();
答案 0 :(得分:4)
您可以使用来自loadFromJSON(url,callback)
的回调<pre>
canvas.loadFromJSON(url, function () {
//first render
canvas.renderAll.bind(canvas);
//before call to zoomOut();
zoomOut();
});
function zoomOut() {
var objects = canvas.getObjects();
console.debug(objects);
......
}