uniapp 请求封装js自动换行复制// 从配置文件中引入配置好的默认路径 import config from "./config.js" class Request { /** * BASEURL -> 请求路径(公用) * method -> 请求方式 * url -> 请求路径 * data -> 请求数据 * header -> 请求头 * responseType -> 返回数据类型 */ request({ BASEURL = config.BASEURL, method = "POST", url, data, header = { "Content-Type": "application/json" }, responseType = "text", }) { return new Promise((resolve, reject) => { uni.request({ url: `${BASEURL}/${url}`, method, data, header, responseType, success: (res) => { resolve(res) }, fail: (err) => { reject(err) }, }) }) } } const http = new Request() export { http } 41 行
评论区
评论加载中...