Use of async\await

1 Call of async function

created(){
    
    
   this.portData();
 },
 methods:{
    
    
   async portData(){
    
    
     const res = await this.start()
     console.log(this.start())
     console.log(res)
   },

   start(){
    
    
     return new Promise(resolve => {
    
    
       setTimeout(function(){
    
    
         let obj = {
    
    
           name:'刘邦'
         };
         resolve(obj)
       },3000)
     })
   },
 }
}

Guess you like

Origin blog.csdn.net/qq_41752378/article/details/129811310