async await初体验

普通请求
demonstration(){
//封装的接口名,具体怎么封装axios 下篇博客会讲到
demo({
id:‘1’,
name:‘测试数据’,
title:‘测试数据’
})
.then((res)=>{
console.log(res)
}
}

//看看async await的写法 请求变得优雅了很多
async demonstration(){
const res = await demo({
id:‘1’,
name:‘测试数据’,
title:‘测试数据’
})
console.log(res)
}

猜你喜欢

转载自blog.csdn.net/weixin_42821697/article/details/109307357