前端上传的几种方式
作者:互联网
1. 转换成二进制
const requestMethod = (file) => { let reader = new FileReader(); reader.readAsArrayBuffer(file.raw); reader.onload = function (event) { console.log(event.target.result); let res = event.target.result; state.curFile = res; };; };
2. formData
const requestMethod = (file) => { let formData = new FormData(); formData.append('file', file.raw) };
标签:前端,event,raw,let,file,reader,几种,上传,formData 来源: https://www.cnblogs.com/huanhuan55/p/16500880.html