Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
516 views
in Technique[技术] by (71.8m points)

使用vue-cropper裁剪完图片怎么返回图片

this.$refs.cropper.getCropBlob((datas) => {
    this.option.img = datas
    console.log(datas)
  })

返回的是这个是怎么回事??,因为要将裁剪完的图片上传给后台而不是base64格式,求指教!!
image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

我们的做法是,后台兼容 Base64 格式的图片上传

这个对于后端来说,又不是很麻烦的事情,截取头信息,把剩下的内容 base64 decode,然后写入文件即可.

只是由于 base64 编码的问题,会导致上传的数据量多了1/3. 如果后台设置了最大上传大小,需要注意下这个编码后可能会超掉.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...