且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 javascript/jquery 中将 base64 转换为图像

更新时间:2023-01-23 08:00:19

你可以只创建一个 Image 对象并将 base64 作为它的 src,包括 >data:image... 部分 像这样:

You can just create an Image object and put the base64 as its src, including the data:image... part like this:

var image = new Image();
image.src = 'data:image/png;base64,iVBORw0K...';
document.body.appendChild(image);

这就是他们所说的数据 URI",这里是 兼容性表,让您内心平静.

It's what they call "Data URIs" and here's the compatibility table for inner peace.