zhangxiaoxu123
2022-07-29 ce114e1f7e349559c1abd106b83d7595d8646393
utils/index.js
@@ -7,8 +7,7 @@
      "Content-type": 'application/x-www-from-urlencoded'
   },
   headerPOST: {
      // "Content-type":'application/json'
      'Content-Type': 'application/x-www-form-urlencoded'
      "Content-type":'application/json'
   },
}
@@ -19,17 +18,22 @@
   return fetch(url, opt)
}
// get请求
export const reqGet = (url, params, opt = {}) => {
// get请求
// 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;
   return fetch(url, opt)