118

https://zh.javascript.info/fetch

async test() {
  let response = await fetch('good4/test/1.jpg');

  let blob = await response.blob(); // 下载为 Blob 对象
  const progressBar_max = document.getElementById("progressBar_max");

  progressBar_max.innerHTML = `${(blob.size / 1024 / 1024).toFixed(3)}MB`;

  // 为其创建一个 <img>
  let img = document.createElement('img');
  img.style = 'width:100px';
  document.body.append(img);

  // 显示它
  img.src = URL.createObjectURL(blob);
},
H5页面 Camila Waz 2022-10-03 12:12:10
430访问人次
Camila Waz 2022-03-15 15:13:54
2

https://zinoui.com/blog/ajax-request-progress-bar

download() {
    var progressBar = document.getElementById("progress");
    var progressBar_value = document.getElementById("progressBar_value");
    var progressBar_max = document.getElementById("progressBar_max");

    var xhr = new XMLHttpRequest();
    xhr.open("GET", "/good4/1.jpg?" + Math.floor(Math.random() * 99999), true);
    xhr.responseType = "text";
    xhr.onprogress = function (e) {
        console.log(e)
        if (e.lengthComputable) {
        progressBar.max = e.total;
        progressBar.value = e.loaded;
        progressBar_value.innerHTML = `${(e.loaded / 1024 / 1024).toFixed(3)}MB`;
        progressBar_max.innerHTML = `${(e.total / 1024 / 1024).toFixed(3)}MB`;
        }
    };
    xhr.onloadstart = function (e) {
        progressBar.value = 0;
    };
    xhr.onloadend = function (e) {
        progressBar.value = e.loaded;
    };
    xhr.send(null);
}
H5页面 Camila Waz 2022-10-02 11:10:49
H5页面 Camila Waz 2022-10-01 16:25:55
7
let num = 0
const imageObj = new Image();
const timer = setInterval(() => {
    document.getElementById('time').innerHTML = num++
    imageObj.onload = () => {
      document.getElementById('img').src = imageObj.src
      console.log(num)
      clearInterval(timer);
    }
},1000)

imageObj.src = 'http://good1230.com/templates/test_img/1.jpg';
H5页面 Camila Waz 2022-10-01 11:53:21
16
const text = `日志异常内容:${err}`
const blob = new Blob([text], {type: 'text/plain'});
let formData = new FormData();
  formData.append("file", blob, `${new Date().getTime()}.txt`);

uploadException(formData).then(res => {

})
H5页面 Camila Waz 2022-09-29 23:33:05
H5页面 Camila Waz 2022-09-05 12:15:43
H5页面 Camila Waz 2022-09-05 12:12:53