一、400状态码前端
application/json
若后端的请求头是:ios
application/x-www-form-urlencoded
application/x-www-form-urlencoded表示:数据被编码为名称/值对。这是标准的编码格式。
若前端发送post请求时的参数以json格式发送就会报400,
this.$http.post({ url:'/v1/assets', data:{ name: this.form.name, categoryType: this.form.type, categoryName: this.form.type === "power" ? "电源" : "其余配件", fee: 123.5, factoryId: 1 }
修改方法:对请求的参数进行 序列化成URL造成发送。json
使用qs库的qs.stringify方法便可。axios