async/await
1). async和await
a. 作用?
简化promise对象的使用: 不用再使用then()来指定成功/失败的回调函数
以同步编码(没有回调函数了)方式实现异步流程
b. 哪里写await?
在返回promise的表达式左侧写await: 不想要promise, 想要promise异步执行的成功的value数据
c. 哪里写async?
await所在函数(最近的)定义的左侧写async
例如
async test(){
}
const te = await test();//te就是test的返回值为undefined,te的结果是这个函数执行成功的值
//如果不加await test()返回的就是一个promise 反之返回了就是成功的值