Api 在vue.js中下载带有blob的pdf文件

Api 在vue.js中下载带有blob的pdf文件,api,vue.js,request,vuex,vue-router,Api,Vue.js,Request,Vuex,Vue Router,有谁知道,为什么我的PDF从blob下载:http://localhost:8080/ 请求: downloadFile : async ({ dispatch }, filename) => { console.log(filename) Vue.http.get(`https://test.io/` + filename, {responseType: 'arraybuffer'}).then(response => { return respon

有谁知道,为什么我的PDF从blob下载:http://localhost:8080/

请求:

  downloadFile : async ({ dispatch }, filename) => {
    console.log(filename)
    Vue.http.get(`https://test.io/` + filename, {responseType: 'arraybuffer'}).then(response => {
      return response
    }).then(response => {
      const fileURL = window.URL.createObjectURL(new Blob([response.data]));
      const fileLink = document.createElement('a');
      fileLink.href = fileURL;
      console.log(response)
      fileLink.setAttribute('download', filename);
      document.body.appendChild(fileLink);
      fileLink.click();
    });
  },
行动:

<button @click="downloadFile(decodeURIComponent(file.substr(file.lastIndexOf('/') + 1)))">
Download
</button>

下载