zoukankan      html  css  js  c++  java
  • vue-axios发送并发请求

      axios发送并发请求,也就是同时发送多个请求,当多个请求响应完毕,再统一拿到全部的数据进行处理。axios提供了此API让我们做到。

    axios.all([axios({
      url: 'http://httpbin.org/',
      method: 'get'
    }),axios({
      url: 'http://httpbin.org/',
      method: 'get'
    })]).then(results => {
      console.log(results[0])
      console.log(results[1])
    })

      results是一个数组,数组元素是封装着各个请求的响应结果。还有一种写法,如下:

    axios.all([axios({
      url: 'http://httpbin.org/',
      method: 'get'
    }),axios({
      url: 'http://httpbin.org/',
      method: 'get'
    })]).then(axios.spread((res1,res2) => {
      console.log(res1)
      console.log(res2)
    }))
  • 相关阅读:
    注释
    选择器
    SQL语句中查找字符的位置
    SQL语句中截取字符串Substr
    IDENTITY(函数)
    SQL Server设置主键自增长列
    SQL语句操作ALTER
    表的主键
    南京夜市
    夜班
  • 原文地址:https://www.cnblogs.com/ibcdwx/p/14644196.html
Copyright © 2011-2022 走看看