Meh*_*ker 1 javascript blob image web-frontend
我的函数在控制台中登录时会返回一个blob对象:
Blob(623853) {name: "profile.jpg", size: 623853, type: "image/jpeg"}
Run Code Online (Sandbox Code Playgroud)
我想用JavaScript向用户显示此图像,我该怎么做?
尝试
const blobUrl = URL.createObjectURL(blob) // blob is the Blob object
Run Code Online (Sandbox Code Playgroud)
上面的代码行应生成一个Blob URL,您可以将其设置为图像源。
image.src = blobUrl // image is the image element from the DOM
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2333 次 |
| 最近记录: |