Function: getImgBase64

getImgBase64(url): Promise<string>

获取图片的base64 url

Parameters

Name Type Description
url string 图片url

Returns

Promise<string>

Promise解析后的图片base64信息

Example

getImgBase64('https://example.com/image.png')
.then(base64 => console.log(base64))
.catch(err => console.error(err));

Example

async function example() {
  try {
    const base64 = await getImgBase64('https://example.com/image.png');
    console.log(base64);
  } catch (err) {
    console.error(err);
  }
}
ON THIS PAGE