美文网首页
vue处理文件流 点击下载文件

vue处理文件流 点击下载文件

作者: 吃肉肉不吃肉肉 | 来源:发表于2021-03-02 14:45 被阅读0次
    download(item){
        this.name=item.class
        var that =this
         apis.GetFiles({id:item.id}).then(res => {
                 that.downloadGO(res)
              }).catch(() => {
              })
        },
        downloadGO (data) {
          if (!data) {
              return
          }
          let url = window.URL.createObjectURL(new Blob([data]))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', this.name)
          document.body.appendChild(link)
          link.click()
    

    相关文章

      网友评论

          本文标题:vue处理文件流 点击下载文件

          本文链接:https://www.haomeiwen.com/subject/ultxqltx.html