請求中使用參數(shù)用form-data的形式: var content = new window.FormData(); content.append("id", this.id); content.append("name", this.name); this.$http.post("test", content) .then(function (data) { if(data.status === 200 && data.ok === true){ this.tipsmessage = '保存成功' this.success = true }else{ this.tipsmessage = '保存失敗' this.success = false } }) .catch( function (data) { console.log('請求出錯(cuò)') } )頁面?zhèn)鬟f參數(shù)效果:為什么傳遞格式不是這樣呢?根據(jù)大家的回答,我做了修改:this.$http({ url: 'test', method: 'POST', data: content, headers: { 'Content-Type': 'application/x-www-from-urlencoded' } })結(jié)果:content-type已經(jīng)修改成application/x-www-from-urlencoded這個(gè)格式了,但是沒有顯示傳遞的參數(shù),為什么呢?
fromdata傳遞數(shù)據(jù)
胡說叔叔
2019-02-27 17:27:46