场景:前端使用JSON.stringify传递到后台之后报错了,后端发现多了个冒号,在控制台打印出来发现没有冒号。在network中查看数据的时候发现多了个冒号。
解决:审查元素 Network 选项卡 Request Headers,contentType的默认是application/x-www-form-urlencoded表单格式,将contentType改为application/json
前端是使用vue,封装的axios
export function getList(data) {
return request({
url: '/getList',
method: 'post',
data: data,
headers: {
'Content-Type': 'application/json'
}
})
}
————————————————
原文链接:https://blog.csdn.net/weixin_43043994/article/details/101058969