fabric.Image.fromURL('图片', (img, isError) => {
img.set({
scaleX: this.canvas.width / img.width,
scaleY: this.canvas.height / img.height,
// width: this.canvas.width,
// height: this.canvas.height,
// Needed to position backgroundImage at 0/0
// originX: 'left',
// originY: 'top'
left: 0,
top: 0
});
this.canvas.setBackgroundImage(img, this.canvas.renderAll.bind(this.canvas));
});
切记: scaleX和 scaleY不要重复配置,否则不生效,坑