-
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 编译出错 #3504
Comments
欢迎提交 Issue~ 如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏 如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。 Good luck and happy coding~ |
children 换个名字试试 |
CC @yuche |
先用一个标签把 citys 包起来吧 renderCityColumns = children => (
<Block>
{
children.length && children.map((item, index) => {
let citys = null;
if(( index + 1 ) % 3 !== 0 && index !== children.length -1 ) {
citys = null;
}
if (( index + 1 ) % 3 === 0 ) {
citys = (
<View className="city-column">
<View className="city-btn">{item[index-2].label}</View>
<View className="city-btn">{item[index-1].label}</View>
<View className="city-btn">{item.label}</View>
</View>
)
}
if(index === children.length -1 && ( index + 1 ) % 3 === 1) {
citys = (
<View className="city-column">
<View className="city-btn">{item.label}</View>
</View>
)
}
if(index === children.length -1 && ( index + 1 ) % 3 === 2) {
citys = (
<View className="city-column">
<View className="city-btn">{item[index-1].label}</View>
<View className="city-btn">{item.label}</View>
</View>
)
}
return <View>{citys}</View>
})
}
</Block>
) |
cncolder
pushed a commit
to cncolder/taro
that referenced
this issue
Mar 3, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题描述
在组件中使用 map 编译出错
复现步骤
[复现问题的步骤]
在组件中使用 map 处理逻辑报错
期望行为
正常编译显示
报错信息
系统信息
System:
OS: macOS High Sierra 10.13.6
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.13.0 - /usr/local/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]
The text was updated successfully, but these errors were encountered: