|
问题
和JAVA 对接口,参数一直传不过去(前端报400错误,后端报传递的参数错误),header也改了,参数传不传字符串都不行 代码如下: this.$axios.post('/api/chuli/deleteByIds',
{
ids: this.ids
},
{
headers: {
'Content-Type': 'application/json'
}
}).then((res) => {
console.log(res)
})原因 最后,终于找到原因了,后端接口,不需要传递键值的形式,直接传数据就好 解决方案 this.$axios.post('/api/chuli/deleteByIds',this.ids),
{
headers: {
'Content-Type': 'application/json'
}
}).then((res) => {
console.log(res)
})注意,post 方法的第二个参数,不是对象,直接传数据就好了 或者,使用 data 传递 this.$axios({
url: '/api/chuli/deleteByIds' ,
method: 'post',
headers: {
'Content-Type': 'application/json'
},
data:this.ids
}).then((res) => {
console.log(res)
})同样注意,data 的值不是对象,直接写要传递的值即可 |
|
|