// util.js
function bigbear (method, url, data, header) {
return new Promise((resolve, reject) => {
wx.request({
url: `https://xxxxxx/ggst${url}`,
method: method,
header: header,
success: resolve,
fail: reject
})
})
}
module.exports = {
bigbear
}
//当然你也可以把加载加上去 wx.hideLoading(); wx.showLoading();
//index.js
const util = require('../../utils/util.js') //引入
onLoad(){
this.aa()
},
aa(){
let data = {xx}
let header ={xx}
util.bigbear('POST', '/app/xxx/index', data ,hearder).then(res => {
console.log(res);
})
},
更多链接:https://www.cnblogs.com/wuliujun521/p/11458379.html