我正在尝试向画布添加一组项目,但希望在添加时将该组设置在zorder堆栈的底部。下面是我想要做的代码:
//Reload the SVG now
var site_url = "/components/<?=$designObj->svg_filename?>";
fabric.loadSVGFromURL(site_url, function(objects, options) {
let componentObj = fabric.util.groupSVGElements(objects, options);
componentObj.setControlVisible(false);
componentObj.sendToBack(); //THIS DOESNT WORK - THROWS TYPE ERROR
componentObj.selectable = false;
componentObj.jdeation_comp_id = "base";
componentObj.jdeation_base_svg = "<?=$designObj->svg_filename?>";
canvas.add(componentObj).renderAll();
});
当我调用sendToBack()时,我得到了以下错误:
TypeError: Cannot read property 'sendToBack' of undefined
我不确定我完全理解这里发生了什么,似乎sendToBack希望类型不是组或其他什么。有没有更好的方法来做这件事?
发布于 2018-12-23 15:45:28
您不能对尚未添加到画布的对象执行.sendToBack()
操作。使用canvas.insertAt(componentObj, 0)
而不是canvas.add(componentObj)
来指定应将对象添加到堆栈底部。
https://stackoverflow.com/questions/53904417
复制相似问题