在挂载组件时,它会启动4个http请求(使用Axios)以获取所需的适当数据。有没有办法监视任何挂起的HTTP请求?
所以基本上:
是否有任何挂起的HTTP请求?
是-> Loading=true
没有-> Loading=false
发布于 2020-07-16 17:16:32
您可以使用Promise.allSettled() (MDN Docs):
const request1 = axios.get('https://api.coindesk.com/v1/bpi/currentprice.json');
request1.then( ... );
const request2 = axios.get('https://api.coindesk.com/v1/bpi/currentprice.json');
request2.then( ... );
Promise.allSettled([request1, request2]).then(() => this.loading = false);https://stackoverflow.com/questions/62931027
复制相似问题