ThinkJS 2.0 中文文档��� catch ��������� ��� �� async/await ������������������������������������� ����������� Promise.all ���� ������ export default class extends think.controller.base { async indexAction(){ console.log(err.stack); }) } }) JavaScript ���� ����� p1 � p2 ���������� Promise.all ��� 2 �������������� ����������������� ThinkJS ������������������������������������� common = this.getServiceData1(); let p2 = this.getAPIData2(); let [p1Data, p2Data] = await Promise.all([p1, p2]); } } JavaScript ���� �� ���� drwxr-xr-x 5 welefen staff 170 Aug 18 15:550 码力 | 238 页 | 1.87 MB | 1 年前3
ThinkJS 2.1 Documentationexecution efficiency. For this, you can use Promise.all to implement it. p1 and p2 are processed parallelly and then get both data by using Promise.all . If your projects need to output data like = this.getServiceData1(); let p2 = this.getAPIData2(); let [p1Data, p2Data] = await Promise.all([p1, p2]); } } JavaScript Output Images export default class extends think.controller.base0 码力 | 148 页 | 1.69 MB | 1 年前3
ThinkJS 2.2 Documentationmostly you want to excute parallely to have higher execution efficiency. For this, you can use Promise.all to implement it. export default class extends think.controller.base { async indexAction(){ getAPIData2(); let [p1Data, p2Data] = await Promise.all([p1, p2]); } } p1 and p2 are processed parallelly and then get both data by using Promise.all . If your projects need to output data like0 码力 | 156 页 | 2.62 MB | 1 年前3
ThinkJS 2.2 中文文档catch 里就不会有此 类的错误了。 并行处理 使用 async/await 来处理异步时,是串行执行的。但很多场景下我们需要并行处理,这样可以大 大提高执行效率,此时可以结合 Promise.all 来处理。 export default class extends think.controller.base { async indexAction(){ let p1 let p2 = this.getAPIData2(); let [p1Data, p2Data] = await Promise.all([p1, p2]); } } 上面的代码 p1 和 p2 是并行处理的,然后用 Promise.all 来获取 2 个数据。这样一方面代码 是同步书写的,同时又不失并行处理的性能。 如何输出图片 项目中有时候要输出图片等类型的数据,可以通过下面的方式进行:0 码力 | 277 页 | 3.61 MB | 1 年前3
ThinkJS 1.2 中文文档// 分类和⽂文章列表数据都 OK 后渲染模版 return Promise.all([catePromise, articlePromise]).then(function(){0 码力 | 104 页 | 1.29 MB | 1 年前3
共 5 条
- 1













