1.解析POST
前端以这样的方式传参:
后端可以用json.loads(…) 获取json数据:
最后解析出来的数据是这样的:
2.解析GET
前端:
getAllUser(){
let $this=this.$axios.get(this.$server+'/user/getAllUser',{
//和POST的区别就在于,GET需要写明这个params,而POST是直接把params里的键值对写到这个大括号下的
params:{
'type':'user'
}
}).then(function (res){
console.log(res.data)
$this.tableData=res.data.data
})
},
后端:
def getAllUser(request):
type=request.GET.get('type')
print("type=",type)
return JsonResponse({...})