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

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处理文件流 点击下载文件)