axiox下载文件

 axios.request({ url: url, method: method, responseType: 'blob' })
                .then(response => {
                    let data = response.data;
                    let blob = new Blob([data], { type: "" }),
                        objectURL = URL.createObjectURL(blob),
                        $a = document.createElement("a");
                    blob.lastModifiedDate = new Date();

                    $a.setAttribute("href", objectURL);
                    $a.setAttribute("download", this.table.currentRow.name);
                    $a.click();
                    $a = null;
                })

 

posted @ 2020-01-07 12:28  神级尘埃  阅读(377)  评论(0编辑  收藏  举报