为什么有的地方是this.KaTeX parse error: Expected 'EOF', got '有' at position 11: axios.xxx,有̲的地方是ctx.axios.xxx,能不能吧axios所有请求方法,统一封装到一个 http 静态类 和 静态方法 中,统一调用方式?
import {config} from “…/config/config”;
import {promisic} from “./util”;
/**
*/
class Http {
static async request({
url,
data,
method = ‘GET’
}) {
const res = await promisic(wx.request)({
url: ${config.apiBaseUrl}${url},
data,
method,
header: {
appkey: config.appkey
}
})
return res.data
}
// 统一异常处理的方案
}
// wx.request
// promisic(wx.request)({
// url:’’,
// data:data,
// })
//
// promisic(wx.getStorage)
//
// promisic(wx.showToast)()
//动态类型 非常常见, python
// java C# 委托
export {
Http
}