有大佬知道的吗?
用xhr。
仅限同源图片
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function() {
if (this.readyState === 4) {
console.log(this.response); // blob
const blob_url = URL.createObjectURL(this.response);
const img = new Image();
img.src = blob_url;
document.body.appendChild(img);
}
});
xhr.open('get', './1.jpg');
xhr.responseType = 'blob';
xhr.send();
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
3 回答5.1k 阅读✓ 已解决
3 回答1.9k 阅读✓ 已解决
获取文件对象的blob路径: