Skip to content

Commit

Permalink
fix: PicturePreview src 拼接参数时, 判断是否已有 ?
Browse files Browse the repository at this point in the history
  • Loading branch information
netys666 committed Aug 8, 2022
1 parent c775221 commit 1e49919
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/components/PicturePreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,12 @@ class PicturePreview extends Component<PicturePreviewProps, PicturePreviewState>
dLink.click();
});
};
// 在URL后添加随机数以避免浏览器缓存,使crossOrigin生效
img.src = this.imgEl.src + '?' + +new Date();
// 在URL后添加随机数以避免浏览器缓存,使crossOrigin生效(拼接前判断 src 中是否已有 ?)
if (this.imgEl.src && this.imgEl.src.indexOf('?') < 0) {
img.src = this.imgEl.src + '?' + +new Date();
} else {
img.src = this.imgEl.src + '&' + +new Date();
}
};

handleFullChange = e => {
Expand Down

0 comments on commit 1e49919

Please sign in to comment.