axios.all()解决并发请求

	// 获取类别
    loadType() {
    
    
      return this.$axios.get("***/***/gettype?code=type");
    },
    // 获取详情
    loadDetail() {
    
    
      return this.$axios.get("***/***/Detail", {
    
    
        params: {
    
     billcode: this.billcode }
      });
    },
    load() {
    
    
      var that = this;
      this.$axios.all([that.loadType(), that.loadDetail()]).then(
        that.$axios.spread(function(TypeRes, detailRes) {
    
    
          console.log("所有请求完成");
          console.log("请求1结果", TypeRes);
          console.log("请求2结果", detailRes);
        })
      );
    },

猜你喜欢

转载自blog.csdn.net/Dilemma_me/article/details/106708404