微信小程序中使用 async 和 await
在⼩程序的开发⼯具中,勾选 es6转es5语法 下载 facebook的regenerator库中的 regenerator/packages/regenerator-runtime/runtime.js 在⼩程序⽬录下新建⽂件夹 lib/runtime/runtime.js ,将代码拷⻉进去 在每⼀个需要使⽤async语法的⻚⾯js⽂件中,都引⼊(不能全局引⼊) 引入方式 : import regeneratorRuntime from '…/…/lib/runtime/runtime’ runtime.js 文件中需要拷贝的代码如下:(或者自己到github上去拷贝也可以,github连接地址在第二步上已给出) /** Copyright © 2014-present, Facebook, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. */ var regeneratorRuntime = (function (exports) { “use strict”; var Op = Object.prototype; var hasOwn = Op.hasOwnProperty;