-
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,第二层s-for绑定有误 #1223
Comments
欢迎提交 Issue~ 如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏 如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。 Good luck and happy coding~ |
你这个在微信小程序能跑吗,顺便 JSX 源码贴一份字符,不要截图,整个 render 函数一起贴出来。顺便带上你的版本号 |
CC @yuche |
感谢回复~ 微信小程序也跑不起来
this.props.lesson 数据格式如下:
|
下个版本会修复,临时的解决方案是把循环内的 JSX 定义挪一下: const ListCards = Object.keys(this.props.lesson).map(key => {
const curKey = this.props.lesson[key];
return (
<View className="listcard">
<Text className="listtitle">{curKey.name}</Text>
<View className="sublist">
{Object.keys(curKey.sub).map(subkey => {
return (<Text className="listitem">{subkey}</Text>)
// return subkey
});}
</View>
</View>
);
}); |
这种写法会报sub undefined,第二层作用域可能不太对。 |
那你现在就这样: const ListCards = Object.keys(this.props.lesson).map(key => {
const curKey = this.props.lesson[key];
const subs = Object.keys(curKey.sub);
return (
<View className="listcard">
<Text className="listtitle">{curKey.name}</Text>
<View className="sublist">
{subs.map(subkey => {
return (<Text className="listitem">{subkey}</Text>)
// return subkey
});}
</View>
</View>
);
}); |
yuche
added a commit
that referenced
this issue
Nov 26, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
编译成swan后,第二层s-for="$anonymousCallee__15"
但state中,$anonymousCallee__15是在第一层下的。
所以s-for的正确引用应该是s-for="key.$anonymousCallee__15"
The text was updated successfully, but these errors were encountered: