2022-10-03 12:12:10
481阅读
<template>
<div id="progressBar_max"></div>
</template>
<script>
export default {
created: function () {
this.test()
},
methods: {
async test() {
let response = await fetch('good4/test/1.jpg');
let blob = await response.blob();
const progressBar_max = document.getElementById("progressBar_max");
progressBar_max.innerHTML = `${(blob.size / 1024 / 1024).toFixed(3)}MB`;
let img = document.createElement('img');
img.style = 'width:100px';
document.body.append(img);
img.src = URL.createObjectURL(blob);
},
}
}
</script>
https://zh.javascript.info/fetch
最后生成于
2024-06-22 12:07:25
热门推荐:
此内容有帮助 ?
0