文件流转换成需要的文件格式(固定套路)

        axios({
            method: "POST",
            url: "/----/-------",
            responseType: "arraybuffer",
            data: { ...payload },
        }).then((res) => {
            const blob = new Blob([res.data]);
            const objectURL = URL.createObjectURL(blob);
            let btn = document.createElement("a");
            btn.download = "-------.xlsx";  
            btn.href = objectURL;
            btn.href = objectURL;
            btn.click();
            URL.revokeObjectURL(objectURL);
            btn = null;
        })

你可能感兴趣的:(前端)