📌  相关文章
📜  在 javascript 中将本地 url 转换为 base64 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:22.829000             🧑  作者: Mango

代码示例1
var xhr = new XMLHttpRequest();       
    xhr.open("GET", "/path/to/local/image/file", true); 
    xhr.responseType = "blob";
    xhr.onload = function (e) {
            console.log(this.response);
            var reader = new FileReader();
            reader.onload = function(event) {
               var res = event.target.result;
               console.log(res)
            }
            var file = this.response;
            reader.readAsDataURL(file)
    };
    xhr.send()