国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

java - vue-resourse的post請(qǐng)求前端向后端傳值 后端接收null
黃舟
黃舟 2017-05-16 13:43:14
0
1
1431
let adrObj = {
  'consignee': this.contact,
  'address': this.detailAdress,
  'province': this.addArr[0],
  'city': this.addArr[1],
  'area': this.addArr[2],
  'isDefault': this.isDefult === true ? '1' : '0',
  'consigneePhone': '0' + this.phoneNum,
  'id': id,
  'customerCode': this.CUSTOMERCODE
}
this.$http.post('/api/receivingAddress/editMyAddress', adrObj).then((res) => {
   console.log('success', res)
}, (res) => {
   console.log('error', res.data)
})

問題描述,通過這種方式向后端傳參,后端接收到的都是null


1.控制臺(tái)中也有數(shù)據(jù),但是后端接收為null
2.我知道設(shè)置emulateJSON為true的話,已表單的方式提交后端可以接收到參數(shù),但是中文是亂碼的。
3.有沒有解決方式,可以正常使用post提交的

黃舟
黃舟

人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!

全部回復(fù)(1)
劉奇

根據(jù)你的描述,你后臺(tái)能夠接受以x-www-form-urlencoded形式提交的數(shù)據(jù),你的代碼提交的是json數(shù)據(jù),需要修改后臺(tái)。

至于x-www-form-urlencoded提交的數(shù)據(jù)中文亂碼的問題,你在headers中設(shè)置一下charset試試

Vue.http.options.headers = {
  'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}

如果還是不行,修改后臺(tái)

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板