canvas是已经base64编码的图片 怎么传到到后台呢 还是用json吗
fetch('/api/avatarUp',{
method:'POST',
headers: {
'Accept': 'application/json',
'Content-Type':'application/json;charset=UTF-8'
},
body:JSON.stringify({avatar:canvas}),
}).then(res => res.blob())
.then(blob => (
img = window.URL.createObjectURL(blob),
this.setState({img})
)).catch(e => console.log(e))
使用fetch方法是可以将json数据传入到后台的,图片也是可以的
可以参考这篇文章:https://blog.csdn.net/withing...