vue axios 3 的并发请求


vim demon02.vue

<template>
  <div class="home">
  </div>
</template>
<script>
import axios from 'axios'
export default {
  name: 'demon02',
  components: {},
  created() {
    //并发请求:同时进行多个请求,并统一处理返回值
    //并发请求的方法: axios.all()    axios.spread()
    axios.all([
            axios.get('/data.json'),
            axios.get('/city.json')
    ]).then(
            axios.spread((dataRes,cityRes)=>{   //dataRes,cityRes 可以自定义
              console.log(dataRes,cityRes)
            })
    )
  }
}
</script>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM