vue使用Promise

vue使用Promise

new Promise((resolve,reject) => {
    
    
    //这里写调用接口的处理代码
    //成功时调用
    reslove(data)
    //失败时
    reject(data)
}).then(data => {
    
    
      //接口成功调用时处理数据的地方  
    return Promise.reslove(xxx)
}).catch(error => {
    
    
      //接口失败调用时处理数据的地方   
})

猜你喜欢

转载自blog.csdn.net/qq_44255146/article/details/116165099