axios 进度条不显示,发个红包给你
想下载时让显示进度条,但是我的不显示,连 console.log(ProgressEvent);都没有反映,可能没有触发? 帮忙看看是哪里问题,代码在下面。 有下载就是看不到下载进度条。 给看看发给你50元的红包,吃屯饭。 会的联系我,发你红包QQ: 23-56-404-766(去年横线)
var axios = require('axios');
var fs = require('fs')
let ws = fs.createWriteStream('./allimg/atu.exe')
axios({
url:'http://download.skycn.com/hao123-soft-online-bcs/soft/2017_02_22_BaiduPlayer5Setup_5.exe',
responseType:'stream',
onDownloadProgress:function(ProgressEvent){
console.log(ProgressEvent);
var progress = Math.round(ProgressEvent.loaded / ProgressEvent.total * 100) + '%';
console.log(progress);
// 进度完成之后
// if(progress == 100){
//...
// }
}
}).then(res=>{
console.log(res.headers)
res.data.pipe(ws)
// //关闭写入流
// res.data.on('close',function(){
// ws.close()
// })
})
4 回复
只有浏览器支持 https://www.npmjs.com/package/axios
// `onDownloadProgress` allows handling of progress events for downloads
// browser only
onDownloadProgress: function (progressEvent) {
// Do whatever you want with the native progress event
},
跪求,在线等升级为50元红包,刚好很多框架开始琢磨收费正版文档了
<p>@chenkai0520 哈嘎</p>