x-www-form-urlencoded格式怎么传参

封装的请求

//get请求 x-www-form-urlencoded传参封装
const $getForm = (url,params)=>{
    
    
  return HttpRequest.request({
    
    
    url:url,
    params,
    method: 'get',
    headers:{
    
    
      "Content-Type": "application/x-www-form-urlencoded", //请求头要加这个
    }
  });
}

//请求参数格式

const getCapitalByYearList = async (name) => {
    
    
    let params = new URLSearchParams(); //URLSearchParams定义了一些实用的方法来处理 URL 的查询字符串
    params.append("types", name);
    const res = await $getForm($api.subsidyMoney.getCapitalByYearList, params).catch((error) => error);
    console.log(res);
};

成功
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42821697/article/details/124951661
今日推荐