出现原因:使用post方式提交时,如果没有指定Content-Type类型的话,原生FORM表单的Content-Type默认为 “application/x-www-form-urlencoded;而后端一般使用application/json;charset=utf-8格式,导致解析失败。(可以在网络请求头中,请求头、响应头的Content-Type属性查看前端、后端的Content-Type)
解决办法:在post方法的config中加入正确的Content-Type属性this.$request.post(url:xxx,JSON.stringify(resultObj),
{ headers: { 'Content-Type': "application/json;charset=UTF-8" }, }).then((res) => { console.log(res) console.log('新增请求发送完成') this.refreshTable() })
因篇幅问题不能全部显示,请点此查看更多更全内容