在項目根目錄下安裝 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'); }
然後重新啟動項目即可