zhangxiaoxu
2026-01-06 89761212ad3ac02b68276d82c26ab6cd767ea216
utils/index.js
@@ -8,8 +8,6 @@
   },
   headerPOST: {
      "Content-type":'application/json'
      // 'Content-Type': 'application/x-www-form-urlencoded',
   },
}
@@ -21,17 +19,36 @@
}
// get请求
export const reqGet = (url, params, opt = {}) => {
// urlParam是拼接路径的参数
export const reqGet = (url, params, urlParam, opt = {}) => {
   opt.header = typeObj['headerGET'];
   opt.method = "GET";
   opt.data = params;
   return fetch(url, opt)
   return fetch(url, opt ,urlParam)
}
// post请求
export const reqPost = (url, params, opt = {}) => {
   opt.header = typeObj['headerPOST'];
export const reqPost = (url, params,form, opt = {}) => {
   if(form == 'form'){
      opt.header = {'Content-Type': 'application/x-www-form-urlencoded'}
   } else {
      opt.header = typeObj['headerPOST'];
   }
   opt.method = "POST";
   opt.data = params;
   opt.params = params;
   return fetch(url, opt)
}
// put请求
export const reqPut = (url, params,form, opt = {}) => {
    if(form == 'form'){
        opt.header = {'Content-Type': 'application/x-www-form-urlencoded'}
    } else {
        opt.header = typeObj['headerPOST'];
    }
    opt.method = "PUT";
    opt.data = params;
    opt.params = params;
    return fetch(url, opt)
}