鍍金池/ 問(wèn)答/HTML5  HTML/ vue+axios

vue+axios

第一種請(qǐng)求方式:

let customer_id = localStorage.getItem('customer_id')
this.$http.post('/health_record/health_status_list.do',customer_id)

使用這種方式從請(qǐng)求回來(lái)的數(shù)據(jù)是空的

clipboard.png

第二種請(qǐng)求方式:

let param = new URLSearchParams();
param.append('customer_id', customer_id);
this.$http({
    method: 'post',
    url: '/health_record/health_status_list.do',
    data: param
})

使用這種方式就有數(shù)據(jù)
clipboard.png

問(wèn)題描述

問(wèn)題出現(xiàn)的環(huán)境背景及自己嘗試過(guò)哪些方法

相關(guān)代碼

// 請(qǐng)把代碼文本粘貼到下方(請(qǐng)勿用圖片代替代碼)

你期待的結(jié)果是什么?實(shí)際看到的錯(cuò)誤信息又是什么?

回答
編輯回答
維他命

https://www.cnblogs.com/cooll...

這個(gè)是參數(shù)序列化的問(wèn)題

如果我需要發(fā)送序列化參數(shù),我會(huì)引入qs

這樣做的效果就與URLSearchParams相同
(因?yàn)閁RLSearchParams有兼容性問(wèn)題)

建議多看看http相關(guān)知識(shí),學(xué)會(huì)用f12的network調(diào)試ajax請(qǐng)求
http://www.java1234.com/a/jav...

2017年12月9日 09:20
編輯回答
枕邊人
let param = new URLSearchParams();
param.append('customer_id', customer_id);
this.$http.post('/health_record/health_status_list.do',param)

Content-type

2018年9月23日 20:37