Reactjs 我使用fabricjs setbackgroundimage修改背景图像,但画布中的内容是黑色的

Reactjs 我使用fabricjs setbackgroundimage修改背景图像,但画布中的内容是黑色的,reactjs,fabricjs,Reactjs,Fabricjs,我使用setbackgroundimage来修改背景图像,但有时上传的图像在内容显示区域会变成黑色。 我尝试了多种不同的方法,但似乎都不管用。有什么想法吗? 提前谢谢 // my code const that = this; const img = new Image(); img.src = crop.get(); // crop.get () is the operation to process the image and get Base64 img.onl

我使用setbackgroundimage来修改背景图像,但有时上传的图像在内容显示区域会变成黑色。 我尝试了多种不同的方法,但似乎都不管用。有什么想法吗?

提前谢谢

// my code

const that = this;
    const img = new Image();
    img.src = crop.get(); // crop.get () is the operation to process the image and get Base64
    img.onload = function() {
      that.props.useCanvas.setBackgroundImage(img.src, 
      that.props.useCanvas.renderAll.bind(that.props.useCanvas), {
        scaleX: that.props.useCanvas.width / img.width,
        scaleY: that.props.useCanvas.height / img.height
      });
      that.props.useCanvas.renderAll();
      that.props.setIsUpload(false);
    };