const image = new Image()
image.setAttribute('crossOrigin', 'Anonymous') // 解决某些图片跨域(有些图片仍不可使用)
image.src = 'url'
image.onload = (img) => {
let base64 = setBase64(img)
var arr = base64.split(',')
var mime = arr
canvas生成base64转换成可上传文件
![](https://img-home.csdnimg.cn/images/20240711042549.png)