下载jpg格式的图片

downloadJpgImg() {
      this.loading = true
      const data = {
        backSvg: this.tmpDatas.backSvg,
        frontSvg: this.tmpDatas.frontSvg,
        code: this.tmpDatas.code,
        type: 1
      }
      editingServer.downLoadPdfFiles(data).then(res => {
        this.loading = false
        const blob = res// 接口返回的文件流
        const reader = new FileReader()
        reader.readAsDataURL(blob)
        reader.onload = (e) => {
          const a = document.createElement('a')
          a.download = `${this.tmpDatas.code}模板.jpg`
          a.href = e.target.result
          document.body.appendChild(a)
          a.click()
          document.body.removeChild(a)
        }
      })
    },
posted @ 2020-12-31 00:22  温柔本肉  阅读(1196)  评论(0编辑  收藏  举报