-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
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
使用map嵌套时,用this.state得到TypeError: Cannot read property 'file' of undefined #886
Comments
方便麻烦贴一下你的数据源吗 |
从props传过来的keys是这样的 {
'颜色': {
'红': {active: false, disabled: false, name: '红'},
'黄': {active: false, disabled: false, name: '黄'}
},
'大小': {
'M': {active: false, disabled: false, name: 'M'},
'L': {active: false, disabled: false, name: 'L'}
}
} 这里我把props得到的keys给了state的skuKeys. 然后更新的都是skuKeys |
skuKeys 更新问题解决了,这里 不过 |
请问你现在用的版本是哪个 |
@yuche 最新版 1.1.0-beta.10 |
Closed
Closed
Closed
This was referenced Sep 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
其中
this.state.skuKeys
的数据是从上级props中传过来的,如果 把
{this.state.skuKeys[key][k]}
这一句换成keys[key][k].active
就不会报错,不过onClick中setState更新了skuKeys
,比如把其中一项的active设置为true, 调试也显示skuKeys是更新了的,但这里map得到的内容,keys[key][k].active
还是显示falseThe text was updated successfully, but these errors were encountered: