引言
今天在做uniapp开发的过程中,遇到了这个问题,,
出现报错信息为:
[memory-leak] triggerOnEvent called on a deprecated instance
一头懵逼
解决方案
uni.request({
url: "目标地址",
dataType: "json",
responseType: "json",
method: "POST",
data: 数据对象,
header: {
"Content-Type": "application/json",
},
success(resp) {
// 响应处理回调函数
},
fail(e) {
console.log(e);
}
})
主要原因就是其中有这个
responseType: "json"
去掉就可以正常返回了。
就是这个样子
uni.request({
url: "目标地址",
dataType: "json",
method: "POST",
data: 数据对象,
header: {
"Content-Type": "application/json",
},
success(resp) {
// 响应处理回调函数
},
fail(e) {
console.log(e);
}
})
借鉴帖子:
https://developers.weixin.qq.com/community/develop/doc/0006a8fb100f40290c910a8086b800
注意:
这里的dataType
代表着请求参数是json格式,文档中写的意思是:
如果设为 json,会对返回的数据进行一次 JSON.parse,非 json 不会进行 JSON.parse