需要获取内容的文件
Optional
type: "text" | "base64"需要将文件转为什么类型的内容。默认为 "base64"
返回内容
// 获取一个图片的 blob
const imgBlob = await fetch('/test.png').then(res => res.blob())
// 获取 json 文件的 blob
const jsonBlob = await fetch('/test.json').then(res => res.blob())
// 获取图片的base64
const imgBase64 = await getBase64(imgBlob)
// 获取 json 文件内容
const jsonContent = await getBase64(jsonBlob, 'text')
将文件转为 base64