network.js
import {
baseURL
} from './config.js'
export default function(options){
return new Promise((resolve,reject)=>{
wx.request({
url:baseURL + options.url,
method:options.method || 'get',
data:options.data||{},
success:resolve,
fail:reject
})
})
}
config.js
const baseURL = 'http://123.101.12341.2:8080/home/multionsa'
export {
baseURL
}
home.js
import request from '../network.js'
export function getMultiData() {
return request({
url: '/home/multidata'
})
}
首页的js
import {
getMULtiData
} from './home.js'
getMULtiData().then(res=>{
}
)