Vue 下载 blob 流文件

Vue 下载 blob 流文件

      // 下载文件
      showFile(item) {
        this.$http({
          method: 'post',
          url: '/fileApi/downLoadFile',
          responseType: 'blob',
          data: {
            'flieName': item.fileName
          },
        }).then(data => {
          if (!data) {
            return
          }
          let link = document.createElement('a')
          link.href = window.URL.createObjectURL(new Blob([data.data], {
            type: "application/x-xls"
          }))
          link.target = '_blank'
          link.download = decodeURI(item.fileName)
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link)
        })
      },
【版权声明】本博文著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处!
【重要说明】本文为本菜鸟的学习记录,论点和观点仅代表个人不代表此技术的真理,目的是学习和可能成为向别人分享的经验,因此有错误会虚心接受改正,但不代表此时博文无误!
【博客园地址】JayveeWong: http://www.cnblogs.com/wjw1014
【CSDN地址】JayveeWong: https://blog.csdn.net/weixin_42776111
【Gitee地址】Jayvee:https://gitee.com/wjw1014
【GitHub地址】Jayvee:https://github.com/wjw1014
原文地址:https://www.cnblogs.com/wjw1014/p/14467864.html