1. // 提前下载资源
    2. fetch("/path/to/animation.gif")
    3. .then(response => response.blob())
    4. .then(blob => {
    5. // Store blob for later use.
    6. this.cachedAnimationBlob = blob
    7. })
    8. // 生成内存地址使用
    9. this.uniqueAnimationSrc = window.URL.createObjectURL(this.cachedAnimationBlob)

    优势: 当需要更新图片特别是gif需要重头播放时,区别于时间戳方式能节省资源,fetch默认有缓存从缓存读取

    相关链接:
    fetch参数配置
    缓存动画gif
    gif手动重新播放解决办法