import axios from 'axios'
let config = axios.create({
withCredentials: true,
headers:{
'X-Requested-With': 'XMLHttpRequest'
},
onUploadProgress: p => { return 100 * ( p.loaded / p.total ) },
onDownloadProgress: p => { return 100 * ( p.loaded / p.total ) }
})
export default config
import axios from 'config'
axios.post('/喵', {
onUploadProgress (a){
console.log(a)
},
onDownloadProgress (a){
console.log(a)
}
})
因为我每个 axios 请求都需要进度条
所以我希望这两个 Progress 返回的都是百分比而不是 Progress 事件对象,不然每个 axios 请求都要写一次处理 function
应该怎么做啊?