前端Loading等的处理

in 前端 with 0 comment

前后端分离的开发模式下,进入一个页面,前端经常需要发数个请求。
此时页面的loading状态就需要等所有请求完成后取消。

这种需求就是并行处理好所有请求后,继续其它操作。正适合用Promise.all来解决。

Promise.all([occupations(), hobbies(), vehicles(), user()])
  .then(res => {
   this.loading = false;
  })
Comments are closed.