📌  相关文章
📜  如何在打字稿代码示例中检查 url 是否响应

📅  最后修改于: 2022-03-11 14:48:21.936000             🧑  作者: Mango

代码示例1
var myImage = document.querySelector('img');

var myRequest = new Request('flowers.jpg');

fetch(myRequest).then(function(response) {
  console.log(response.ok); // returns true if the response returned successfully
  response.blob().then(function(myBlob) {
    var objectURL = URL.createObjectURL(myBlob);
    myImage.src = objectURL;
  });
});