代码如下:
<script>
import axios from 'axios'
export default {
name: 'HelloWorld',
props: {
msg: String
},
data() {
return {
r1: '',
r2: '',
r3: ''
}
},
created() {
this.getData()
},
methods: {
getData() {
axios.all([
axios.get('http://baidu.com'),
axios.get('https://163.com'),
axios.get('https://google.com')
]).then(
axios.spread(function(r1, r2, r3) {
console.log(r1, r2, r3)
})
).catch(error => console.log(error))
}
}
}
</script>
问题:
期待:
1
Axnir 2022-03-20 18:03:27 +08:00 1
用 Promise.allSettled 吧
|