import axios from ‘axios‘
axios.all([接口名1,接口名2])
.then(axios.spread((响应1,响应2)=>{
?
}))
代码
import { getBanner, getIndexGoods } from "../util/axios";
//单独调用axios
import axios from "axios";
//调用轻提示
import { Toast } from "vant";
?
  data() {
    return {
      bannerList: [],
      newsList: [],
      hotsList: [],
      goodsList: []
    };
  },
 
 mounted() {
    //组件加载获取轮播图接口
    //组件加载获取商品信息
    //并发处理
    axios.all([getBanner(), getIndexGoods()]).then(
      axios.spread((bannerList, indexGoods) => {
        console.log(bannerList, "响应1");
        console.log(indexGoods, "响应2");
        if (bannerList.code == 200) {
          this.bannerList = bannerList.list;
          //   Toast.success(bannerList.msg);
        } else {
          Toast.fail(bannerList.msg);
        }
        if (indexGoods.code == 200) {
          this.newsList = indexGoods.list[0].content;
          this.hotsList = indexGoods.list[1].content;
          this.goodsList = indexGoods.list[2].content;
        } else {
          Toast.fail(indexGoods.msg);
        }
      })
    );
  },
  
原文:https://www.cnblogs.com/2587jsq/p/14226183.html