有大佬知道的吗?
用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();
13 回答12.7k 阅读
2 回答4.9k 阅读✓ 已解决
7 回答1.8k 阅读
5 回答1.3k 阅读
3 回答2.1k 阅读✓ 已解决
8 回答2.2k 阅读
5 回答645 阅读
获取文件对象的blob路径: