const request = (response) => {
return new Promise((resolve, reject) => {
wx.request({
url: response.url,
method:response.method?response.method:'GET',
data:response.data?response.data:null,
success:resolve,
fail:reject
})
})
}
export default request
引入
import request from '../request'
使用
async loadtype() {
const res = await request({
url: '请求地址',
})
//赋值操作
this.setData({
typelist: res.data.data
})
},