Bootstrap

后端URL 转成 blob 链接

const getBlobUrl = (url) => {
 return new Promise((resolve, reject) => {
    const currentProtocol = window.location.protocol;
    let play_url
    if (currentProtocol == "https:") {
      play_url = url.replace("http:", "https:");
    }
    window.URL = window.URL || window.webkitURL;
    var xhr = new XMLHttpRequest();
    xhr.open("GET", play_url, true);
    xhr.responseType = "blob";
    xhr.onload = function (e) {
      if (this.status == 200) {
        var blob = this.response;
        // console.log(e,resolve);
        resolve(window.URL.createObjectURL(blob))  
      }else{
        reject(e)
      }
    };
    xhr.send();
  })
}
;