wepy中使用promise异步请求
1. 安装模块
npm install wepy-async-function --save
2.如何使用?
- 1.引入模块
// app.wpy
import wepy from 'wepy';
import 'wepy-async-function';
- 2.在app.wepy 声明
constructor () {
super()
this.use('requestfix')
this.use('promisify')
}
3.实战
import wepy from 'wepy';
// promise
wepy.getSystemInfo()
.then(res => {
this.globalData.systemInfo = res;
})
// async
async getSystem() {
let res = await wepy.getSystemInfo();
console.log(res);
}