vue axios传中文参数导致乱码的解决方案之encodeURI
axios.get(filterdata, {params: {strCustomer: encodeURI(filterUser),strDt: _this.date},headers: {"Content-Type": "application/x-w...
·
axios.get(filterdata, {
params: {
strCustomer: encodeURI(filterUser),
strDt: _this.date
},
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
},
})
.then(function(res) {
res = res.data;
res = res.substring(res.indexOf("{"), res.lastIndexOf("}") + 1)
if(res == '') {
//plus.nativeUI.toast("获取清单失败");
_this.titleTip = '';
return false;
} else {
res = JSON.parse(res);
_this.titleTip = res.title;
}
});
前台向后台传递参数,参数为中文,导致后台接收的值是乱码,
解决办法:前台先把中文进行编码,后台进行解码,就ok啦
params: {
strCustomer: encodeURI(filterUser),
strDt: _this.date
},
更多推荐
已为社区贡献5条内容
所有评论(0)