首页 > 微信 > 详细

小程序如何支持使用 async/await

时间:2019-10-16 00:34:08      阅读:114      评论:0      收藏:0      [点我收藏+]

下载 regenerator-runtime

npm i regenerator-runtime

如何使用

在小程序中,不认识 node_modules 文件夹,无法通过以下方法来直接找到包文件

import regeneratorRuntime form ‘regenerator-runtime‘

所以需要将 regenerator-runtime 中的 runtime.js(支持async/await的核心文件) 拿出来存放到一个文件夹中,通过一般的文件引入方式使用。

例:

import regeneratorRuntime from ‘../../lib/runtime.js‘

值得一提的是导出的名字必须为 regeneratorRuntime ,否则无法使用async/await

最后

使用过程中如果出现一些意外,我在构建npm版中有记录到一个碰到的错误

使用async/await(构建npm版): https://www.cnblogs.com/chanwahfung/p/11503533.html

小程序如何支持使用 async/await

原文:https://www.cnblogs.com/chanwahfung/p/11681881.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!