Home > @dinofe/xt-core > base64ToBlob

# base64ToBlob() function

Base64 (opens new window) 字符串转为 Blob (opens new window)

Signature:

export declare function base64ToBlob(data: string, mimeType?: MIME_TYPE, sliceSize?: number): Blob;

# Parameters

Parameter Type Description
data string base64 字符串(可以包含'data:image/jpeg;bas64,'会被忽略)
mimeType MIME_TYPE (Optional) MIME 类型
sliceSize number (Optional) 切片大小

Returns:

Blob

Blob 对象

# Example 1

默认用法

import { base64ToBlob, MIME_TYPE } from '@dinofe/xt-core/web'
const base64Str = '...'
const blob = base64ToBlob(base64Str, MIME_TYPE.JPG)

# Example 2

修改配置

import { base64ToBlob, MIME_TYPE } from '@dinofe/xt-core/web'
const base64Str = '...'
const blob = base64ToBlob(base64Str, MIME_TYPE.PNG, 1024)