当前位置: 首页 > news >正文

网站建设费用核算科目陕西省安康市建设局网站

网站建设费用核算科目,陕西省安康市建设局网站,电动车行业网站建设,软件开发怎么样1. 什么是 async/await async/await 是 ES8#xff08;ECMAScript 2017#xff09;引入的新语法#xff0c;用来简化 Promise 异步操作。在 async/await 出 现之前#xff0c;开发者只能通过链式 .then() 的方式处理 Promise 异步操作。示例代码如下#xff1a; import …1. 什么是 async/await async/await 是 ES8ECMAScript 2017引入的新语法用来简化 Promise 异步操作。在 async/await 出 现之前开发者只能通过链式 .then() 的方式处理 Promise 异步操作。示例代码如下 import thenFs from then-fsthenFs.readFile(./files/1.txt,utf8) // 返回值是 promise 的实例对象。 .then(r1{ // 通过 .then 为第一个 Promise 实例指定成功之后的回调函数。console.log(r1)return thenFs.readFile(./files/2.txt,utf8) // 在第一个 .then 中返回一个新的 promise 的实例对象。 }) .then(r2{ // 继续调用 .then 为上一个 .then 的返回值新的 Promise 实例) 指定成功之后的回调函数。console.log(r2)return thenFs.readFile(./files/3.txt,utf8) // 在第二个 .then 中返回一个新的 promise 的实例对象。 }) .then(r3{ // 继续调用 .then 为上一个 .then 的返回值新的 Promise 实例) 指定成功之后的回调函数。console.log(r3) })// 运行结果 // txt file 1 // txt file 2 // txt file 3 .then 链式调用的优点 解决了回调地狱的问题.then 链式调用的缺点 代码冗余、阅读性差、 不易理解 2. async/await 的基本使用 import thenFs from then-fs;//按照顺序读取 123文件的内容 async function getAllFile(){const r1 await thenFs.readFile(./files/1.txt,utf8)// 当在 thenFs.readFile()方法前面添加 await 关键字时返回的不是一个 Promise 实例了而是文件的内容。console.log(r1)const r2 await thenFs.readFile(./files/2.txt,utf8)console.log(r2)const r3 await thenFs.readFile(./files/3.txt,utf8)console.log(r3) } //调用方法 getAllFile();// 运行结果 // txt file 1 // txt file 2 // txt file 3 3. async/await 的使用注意事项 如果在 function 中使用了 await则 function 必须被 async 修饰在 async 方法中第一个 await 之前的代码会同步执行await 之后的代码会异步执行 import thenFs from then-fs;console.log(A) //按照顺序读取 123文件的内容 async function getAllFile(){console.log(B)const r1 await thenFs.readFile(./files/1.txt,utf8)const r2 await thenFs.readFile(./files/2.txt,utf8)const r3 await thenFs.readFile(./files/3.txt,utf8)console.log(r1,r2,r3)console.log(D) }//调用方法 getAllFile(); console.log(C)// 运行结果 // A // B // C // txt file 1 // txt file 2 // txt file 3 // D
http://www.tj-hxxt.cn/news/225783.html

相关文章:

  • 宁波专业网站推广平台咨询站群cms建站系统免费
  • 织梦大气金融类通用企业网站模板ps设计一个手机ui界面
  • 毕业设计可以做哪些网站wordpress gold
  • 网站诊断与优化的作用网站建设价格比较
  • 仿公众号网站请输入您网站的icp备案信息
  • 做旅游攻略的网站代码lcms是什么意思
  • 只做正品的购物网站南昌哪里做网站
  • 动态背景设置网站营销公关
  • 官方网站开发模板方舟网站建设
  • 企业网站建设哪家最好做网站维护的是什么公司
  • 吉林市城市建设管理执法局网站北京互联网公司待遇排名
  • 成都建设网站那家好wordpress不同页面显示不同文章
  • wordpress直接上传视频网站app制作开发
  • 源码搭建网站流程灯具电商网站建设方案
  • asp网站采集电子商务公司经营范围有哪些
  • 网站优化细节ui设计培训班学费
  • 扎金花网站怎么做wordpress媒体库数据
  • 顺德网站制作案例市场热门的网页设计工具有哪些
  • 南通网站制作域名如何指向网站
  • dede 中英文网站 怎么做创建网站购买域名要注意什么
  • 域名可以绑定网站吗广州地铁18号线最新线路图
  • 环境网站模板济宁网站建设流程
  • 移动版网站开发黄页网站怎么查
  • 做网站外包好做吗广告公司取什么名字好
  • 高大上的企业网站欣赏南宁百度seo价格
  • 基础网站建设素材张雪峰不建议报的计算机
  • 水务 网站建设拍摄宣传片的流程简要
  • 企业网站后台管理模板展厅设计公司首选
  • 做ppt好的模板下载网站北京工程设计公司排名
  • 企业网站制作步骤燕窝网站怎么做的