async\await 的使用

1 async函数的调用

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)
     })
   },
 }
}

猜你喜欢

转载自blog.csdn.net/qq_41752378/article/details/129811310