vue前端API接口封装调用(前后端分离)
get和post的传参是不同的
1.封装接口的时候get传参需要用params,post传参直接写data就行
2.get调用的时候需要写传参的(键值对)就可以传参成功了,post 调用的时候就是直接写你的要传的参数
export function getAdmin(data){
return request({
url:' ... ',
method:'get',
params:data
})
}
testData(){
getAdmin({"sort":"update_time,desc"}).then(res=>{
console.log(res)
});
},

浙公网安备 33010602011771号