这是我的js代码:
for (tagTemplateImage in tagTemplateImages) {
var templates = tagTemplateImages[tagTemplateImage];
for (templateId in templates) {
$('.template-container').prepend('<div class="canvas col-lg-12" data-template-id="' + templateId + '"><canvas id="c-' + canvasIndex + '" data-index="' + canvasIndex + '" data-template-id="' + templateId + '" width="433" height="433" style="border:1px solid #ccc"></canvas></div>');
canvas[canvasIndex] = new fabric.Canvas('c-' + canvasIndex, { preserveObjectStacking: true });
canvas[canvasIndex].loadFromJSON(templates[templateId], canvas[canvasIndex].renderAll.bind(canvas[canvasIndex]));
var canvastObjects = canvas[canvasIndex].getObjects();
console.log(canvastObjects); //--> objects with properties
console.log(canvastObjects.length); //--> 0
for (o in canvastObjects) {
console.log(o);//--> nothing shows here
}
}
}
在for循环部分,它不会记录任何内容。
Here is the image for the logging of objects
感谢您的帮助!