一. axios 上传文件
使用 FormData
对象上传
const param = new FormData();
param.append('key', fileList[0].raw/*此参数为文件*/)
axios.post(api, param).then(res => {
console.log(res.data)
})
二. 将字符串作为 txt 文件上传: new Blob(['xxxxxstringxxx']
const fileList = [];
fileList.push({name: a.txt, raw: new Blob(['xxxxxstringxxx'])})
三. 下载
比如下载地址是 downloadAPI
,直接 window.open(downloadAPI)
.
网友评论