Merge pull request #10 from T1ipoca/fix/crossorigin-image-loads
fix: 跨域托管静态资源时 new Image() 缺少 crossOrigin 导致渲染失败
This commit is contained in:
2 files changed
+2
No files matched your search
@@ -417,6 +417,7 @@ export function loadImageElement(url) {
|
||||
if (typeof Image === 'undefined') { reject(new Error('no Image in this environment')); return; }
|
||||
const img = new Image();
|
||||
img.decoding = 'async';
|
||||
img.crossOrigin = 'anonymous';
|
||||
img.onload = () => resolve(img);
|
||||
img.onerror = () => reject(new Error(`image failed: ${url}`));
|
||||
img.src = url;
|
||||
|
||||
@@ -67,6 +67,7 @@ function preload(url) {
|
||||
if (!url || typeof Image === 'undefined') return;
|
||||
const img = new Image();
|
||||
img.decoding = 'async';
|
||||
img.crossOrigin = 'anonymous';
|
||||
img.src = url;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user