data(){
return {
list: [1, 2, 3]
}
},
created(){
let arr = [];
this.list.map(item => {
arr.push(this.getClassify(item))
});
let promise = Promise.all(arr).then(res => {
console.log("Promise.all", res, res.length);
});
},
methods:{
getClassify(item) {
return new Promise((resolve, reject) => {
resolve(item * item);
});
},
}
网友评论