Today's front-end developers are basically used to Promises, but they don't know why the WeChat applet doesn't support it! not support! not support! (Important said three times)
Then there is no way, we can only introduce it manually;
I use bluebird here, others can copy my method;
npm install bluebird --save
Then you can import the file, like me
const Promise = require('../libs/bluebird.min')
Then you can use Promises in the file, for example:
export function GET_REQ (url) {
return new Promise((reslove, reject) => {
wx.request({
url: domain + url,
method: 'GET',
success: function (res) {
reslove(res)
},
fail: function (err) {
reject(`网络连接失败${err}`)
}
})
})
}