We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
多处 setData 的场景:
setData
const obj = {}
setTimeout
覆盖
The text was updated successfully, but these errors were encountered:
对于复杂数据,多处 setData 没有问题!所以切记,不要轻易替换复杂数据的指针!比如:
const { o } = this.data; this.setData({ o: o.concat([1, 2, 3]), });
虽然麻烦,真的不如下面这个代码:
const { o } = this.data; [1, 2, 3].forEach(it => { o.push(it); }); this.setData({ o, });
这样子可以避免很多的隐藏坑!
Sorry, something went wrong.
No branches or pull requests
多处
setData
的场景:setData
一下,这个其实是错误的编码,还会有性能问题! -- 这种场景应该用const obj = {}
,所有数据都处理完再一次性setData
来解决setTimeout
,这个时候如果用setTimeout
函数外的闭包变量来setData
的话,就会很危险,因为可能会用旧的数据覆盖
掉setTimeout
期间其他地方setData
的数据!The text was updated successfully, but these errors were encountered: