小程序中是用es7的async/await

500 阅读1分钟

1.在小程序开发工具中,勾选es6转es5语法

2.进入facebook的regenerator库中的github.com/facebook/re…

3.在小程序目录下新建文件夹lib/runtime/runtime.js,把代码全部拷贝过去

4.在每一个需要使用async的js中引入,不能全局引入

import regeneratorRuntime from "../../lib/runtime/runtime";

5.把runtime.js中代码的最后一行注释掉,不然会报错

    // Function("r", "regeneratorRuntime = r")(runtime);