小编man*_*the的帖子

Fabricjs 无法在“WebGLRenderingContext”上执行“texImage2D”:图像元素包含跨域数据,可能无法加载

我正在使用 Amazon S3 和云前端。图片网址看起来像https://t.pimg.jp/061/089/535/2/61089535.jpg

我的代码看起来像

const imgUrl = 'https://t.pimg.jp/061/089/535/2/61089535.jpg';
fabric.util.loadImage(imgUrl, function(imgObj) {
    const oImg = new fabric.Image(imgObj, {
        crossOrigin: 'anonymous',
    });

    ...
});
Run Code Online (Sandbox Code Playgroud)

图片加载成功。但是当我对该图像应用过滤器时,就会出现错误。

已经在 s3 存储桶中应用了 cors 配置

<CORSConfiguration>
 <CORSRule>
   <AllowedOrigin>*</AllowedOrigin>
   <AllowedMethod>GET</AllowedMethod>
   <AllowedHeader>*</AllowedHeader>
 </CORSRule>
</CORSConfiguration>
Run Code Online (Sandbox Code Playgroud)

有谁知道如何修复?

fabricjs reactjs

1
推荐指数
1
解决办法
3291
查看次数

标签 统计

fabricjs ×1

reactjs ×1