urlToBase64(url)?{
??????return?new?Promise((resolve,?reject)?=>?{
????????let?image?=?new?Image();
????????image.onload?=?function?()?{
??????????let?canvas?=?document.createElement("canvas");
??????????canvas.width?=?this.naturalWidth;
??????????canvas.height?=?this.naturalHeight;
??????????//?將圖片插入畫布并開始繪制
??????????canvas.getContext("2d").drawImage(image,?0,?0);
??????????//?result
??????????let?result?=?canvas.toDataURL("image/jpeg");
??????????resolve(result);
????????};
????????//?CORS?策略
????????image.setAttribute("crossOrigin",?"Anonymous");
????????image.src?=?url;
????????//?圖片加載失敗的錯(cuò)誤處理
????????image.onerror?=?()?=>?{
??????????reject(new?Error("urlToBase64?error"));
????????};
??????});
????},