文件下載、文件流

// 文件下載
  downloadFile (url, param = {}) {
    let paramAll = Object.assign({ _cache: Date.now() }, param);
    return new Promise((resolve, reject) => {
      axios({
        method: 'get',
        url,
        responseType: 'blob',
        params: paramAll
      }).then(res => {
        resolve(res);
      }).catch(error => {
        reject(error);
      });
    });
  }

前端以文件流方式下載方法。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章