封装的请求
//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);
};
成功