- 当前 Bug 的表现(可附上截图)
- 预期表现
- 复现路径
- 提供一个最简复现 Demo
wepy.request({
url: url,
header: {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
},
data: JSON.stringify(p),
method: meth,
success: function (res) {
console.log('--success--')
console.log(JSON.stringify(res))
if(res.data.status == 0){
let resp = JSON.parse(res.data.payload)
if(resp.Data != null){
callback(resp)
}
}else{
console.log('--未知问题--'+res.data.status)
}
},
fail: function (err) {
console.log('--wx send fail--')
console.log(JSON.stringify(err))
}
})
}
data里边含有中文,导致服务器收到的是乱码,返回不了正确数据,应该怎么才能让服务器接收到正常的中文呢,在网上查有人说header改一下,还有的说用
const json2Form = function (json) {
var str = [];
for (var p in json) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(json[p]));
}
return str.join("&");
}
module.exports.json2Form = json2Form
函数来处理中文,我试了也不行,也有可能试用法不错,恳求大佬解答
wepy在这里提问或搜索答案,https://github.com/Tencent/wepy/issues