在项目根目录下安装 runtime 包:
npm install wepy-async-function --save
修改wepy.config.js:
babel: { "presets": [ "env" ], "plugins": [ "transform-export-extensions", "syntax-export-extensions" ] }
在app.wpy中使API promise化 :
import 'wepy-async-function'
在constructor中使用:
constructor () { super() this.use('requestfix') this.use('promisify'); }
然后重新启动项目即可
wepy项目中使用async awite
最新推荐文章于 2022-04-12 17:58:20 发布