多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
### 文件转base64 ``` const reader = new FileReader(); reader.onload = (e) => { var base64Str = e.target.result.split(",")[1] } reader.readAsDataURL(file); ``` ### base64 转文件 ```js function convertBase64UrlToBlob (dataurl, filename) { var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n); while (n--) { u8arr[n] = bstr.charCodeAt(n); } return new File([u8arr], filename || guid() + '.png', { type: mime }); } function guid() {     return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {         var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);         return v.toString(16);     }); } ```