//核心代码,需要使用vue.use全局注册,只需参照博主的封装axios

// import {apiServer} from './../../common.js'
class http {
    static request(url, params = {}, method = "POST", contentType = "application/x-www-form-urlencoded") {
        return new Promise((resolve, reject) => {
            uni.request({
                url, //仅为示例,并非真实接口地址。
                data: params,
                header: {
                    'Content-Type': contentType
                },
                method,
                success: (res) => {
                    resolve(res.data.data);
                }
            });
        })
    }
}
export default http
posted on 2020-01-03 19:01  随心的博客  阅读(15832)  评论(0编辑  收藏  举报