wepy项目中使用Promise

Gcaufy edited this page May 9, 2018 · 4 revisions

在1.4.1以下版本,wepy生成的项目默认都会加入promise polyfill。

在1.4.1以后的版本,需要用户手动加入,具体方法如下:

  • 进入项目根目录,安装polyfill
npm install wepy-async-function --save
  • 在app.wpy中引入polyfill
import 'wepy-async-function'; 
  • 在app.wpy中使API promise化
export default class extends wepy.app {

    constructor () {
        super();
        this.use('promisify');
    }

}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.