FWQ
怎么使微信小程序支持async await?
微信小程序 使用async await 微信小程序并不支持async,写起代码来太不舒服了. 各种回调会造成回调地狱的问题,回调函数一层套着一层,代码难以阅读,后期难以维护的问题 解决办法: 使用regenerator-runtime regenerator-runtime是facebook的regenerator模块 生成器函数、async、await函数经babel编译后,regenerator-runtime模块用于提供功能实现。 引入facebook/regenerator 中的packages/regenerator-runtime/runtime.js 步骤1 引入并注册 因全局都要用到,所有在app.js中引入,并注册全局对象中. app.js import regeneratorRuntime from './lib/runtime' App({ ... regeneratorRuntime, onLaunch(){}, onShow() {}, onHide() {},…