一、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