Search: axios request how to set progress bar
Dom
<progress id="file" max="100" value="80"> 80% </progress>
: The Progress Indicator element - HTML: HyperText Markup Language | MDN
handle progress bar
// handle progress bar function
function handleUploadProgressBar(progress) {
document.querySelector('#file').value = progress;
document.querySelector('#file').innerHTML = progress;
}
// request
axios.put('/update', formData, {
headers: {
"Content-Type": "multipart/form-data",
},
onUploadProgress : (progressEvent) => {
const progress = parseInt(Math.round((progressEvent.loaded * 100) / progressEvent.total));
// Update state here
handleUploadProgressBar(progress);
},
});
// `onUploadProgress` allows handling of progress events for uploads
// browser only
onUploadProgress: function (progressEvent) {
// Do whatever you want with the native progress event
},
// `onDownloadProgress` allows handling of progress events for downloads
// browser only
onDownloadProgress: function (progressEvent) {
// Do whatever you want with the native progress event
},
'✘✘✘ Web' 카테고리의 다른 글
[Javascript][Regex] Regex test does not select all items from a list (0) | 2022.08.22 |
---|---|
Editable Dom => attribute: contentEditable (0) | 2022.07.22 |
Dom id => window[id] or document.querySelector('#id') (0) | 2022.07.22 |
the-dom-challenge: Build something with only vanilla Javascript (0) | 2022.07.22 |
[chrome][devtools] elements tab right click not working (0) | 2022.07.07 |
댓글