基础库2.16.0导致原来setData不能用要怎么解决啊?

小程序 文章 2021-04-06 17:02 361 0 全屏看文

AI助手支持GPT4.0

基础库2.16.0导致原来setData不能用要怎么解决啊?Basic library 2.16.0 leads to the original setData can’t be used.

基础库2.16.0导致原来setData不能用要怎么解决啊?

今天看到原来的getUserInfo被砍了一刀,然后用了getUserProfile发现基础库需要升级,于是升级到最新,发现setData用不了了,这可咋办啊?,救救孩子吧,2.15后台又要改逻辑,唉

Today, I saw that the original getUserInfo was hacked. Then I used getuserprofile and found that the basic library needed to be upgraded. So I upgraded to the latest version and found that SetData was no longer available. What can I do? , save the children, 2.15 backstage has to change the logic, alas

回答:

ᥴꪮꪮꪶ .:

this指向问题

在这个函数的最顶端写

let that = this;

然后把this 改成 that

null:嗯,一时间没反应过来,因为2.15都不会有这个问题
詹迪克:

明显的 this 作用域问题啊 跟getUserProfile无关

null:嗯,一时间没反应过来,因为2.15都不会有这个问题
詹迪克:2.15 用this 也不好使呀
null:改的迷迷糊糊
詹迪克:趁这个契机来一波代码重构。完美    ؏؏☝ᖗ乛◡乛ᖘ☝؏؏
null:那可是大工程了,肝不太行,时间不允许,先上了,出问题再改,时间太赶
brave:

[抠鼻] 叫你好好学js你不听,别甩锅了

null:哈哈哈,原来的基础库都没事,我一开始以为是基础库的毛病
null:

脏话!!!!!!!!!!!!!!!!

解决了,在方法前面let that=this

瞎搞!改来改去,渣渣微信

-EOF-

AI助手支持GPT4.0