赞
踩
// 方法一:get请求传query可以拼接在url后面,也可以放在params中
const age = 15;
const result = await axios.get(`/a?age=${age}&type=1`,{
headers: {
"Content-Type": testApiData.value.extContentType,
},
});
// 方法二:get请求传query也可以放在params中
const query = {
age: 15,
type: 1,
};
const result = await axios.get("/a", {
params: query,
headers: {
"Content-Type": testApiData.value.extContentType,
},
});
// 方法一
const result = await axios.post("/a", body, {
headers: { "Content-Type": "application/x-www-form-urlencoded" },
params: query
});
// 方法二
const query = {
age: 15,
type: 1,
};
const result = await axios({
url: "/a",
method: "post",
data: body,
params: query,
headers: {
"Content-Type": "application/json",
},
});
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。