function urlToBase64(url, callback) { var xhr = new XMLHttpRequest(); xhr.onload = function() { var reader = new FileReader(); reader.onloadend = function() { callback(reader.result); } reader.readAsDataURL(xhr.response); }; xhr.open('GET', url); xhr.responseType = 'blob'; xhr.send(); } var imageUrl = 'https://static.flomoapp.com/file/2023-04-02/19208/1680445554566B00B7ACEC5BE07B8.jpg?OSSAccessKeyId=LTAI4G9PcaGksWVKCPrE1TVL&Expires=1680763399&Signature=Fwxz3MC%2FfECIuyddsuQzC81MmRs%3D'; urlToBase64(imageUrl, function(base64) { console.log(base64); // 输出转换后的 Base64 编码 });