@RequesBody(一般建议post使用@RequestBody接收;get就直接@RequestParam,当然也可以用@PathVariable)
export function test(){
const forms=reactive({
name:'test',
age:20
});
request.get('user/test',forms).then(res=>{
console.log(res);
}).catch(error=>{
return error;
});
request.post('user/test',forms).then(res=>{
console.log(res);
}).catch(error=>{
return error;
});
}
@RequestParam(不直接传,而是要用params)
export function test() {
const forms = reactive({
name: 'test',
age: 20
});
request.get('user/test', {
params: {
name: forms.name,
age: forms.age
}
}).then(res => {
console.log(res);
}).catch(error => {
return error;
});
}