Skip to content

Commit

Permalink
fix: 修复添加图片后,toDataURL 报SecurityError
Browse files Browse the repository at this point in the history
  • Loading branch information
zengyue committed May 12, 2021
1 parent 5e70013 commit 6c9f36f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/graphic/engine/shape/image.js
Expand Up @@ -30,14 +30,15 @@ class ImageShape extends Rect {
if (src && window.Image) {
this.set('loading', true);
const image = new Image();
image.src = src;
// 设置跨域
image.crossOrigin = 'Anonymous';
// 设置跨域, 等同于 image.crossOrigin = 'anonymous'
image.crossOrigin = '';
image.onload = () => {
this.set('loading', false);
this.set('image', image);
this.draw(context);
};
// src 一定要在 crossOrigin 之后,否则 toDataURL 就会报 SecurityError
image.src = src;
}
}

Expand Down

0 comments on commit 6c9f36f

Please sign in to comment.