/**
 * File to Base64
 * @param { File } 文件
 */
const fileToBase64 = (file = new File()) => new Promise((resolve, reject) => {
    let reader = new FileReader();
    reader.onload = () => resolve(`data:${file.type};base64,${reader.result.split(",")[1]}`);
    reader.onerror = () => reject(reader.error);
    reader.readAsDataURL(file);
});

文章作者: CaptainTwo
本文链接:
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 CaptainTwo
JavaScript JavaScript
喜欢就支持一下吧