Camila Waz 发布于
2020-09-22 10:18:46

es6 Promise.all()先后顺序执行方法实例代码

1、Promise.all() 执行结果


2、Promise.all()先后顺序执行方法实例代码

created(){
    Promise.all([this.promise(),this.promise2()]).then((res)=>{
      console.log(res)
      console.log("最后加载的代码! ")
    })
},
methods:{
    promise(){
      return new Promise((resolve,reject)=>{
        const data={
          google: "t-10001",
          operating: "lists",
          page: 0,
          pagesize: 10,
        }
        this.$axios.post('vue/google.php',data).then(res => {
          console.log("方法一加载完成!")
          resolve(res.data.data)
        })
      })
      
    },
    promise2(){
      return new Promise((resolve,reject)=>{
        const data={
          fid: "",
          google: "t-10008",
          operating: "lists",
          page: 0,
          pagesize: 10,
          title: "",
          type: "",
        }
        this.$axios.post('vue/google.php',data).then(res => {
          console.log("方法二加载完成!")
          resolve(res.data.data)
        })
      })
    },
},


当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2020-09-22/540.html
最后生成于 2020-10-09 16:48:07