i listitem列表如果"计数"不是0,我想显示徽章
list.map((l, i) => (
<ListItem
containerStyle={{ width: '100%', borderBottomWidth: 1, borderColor: '#eee'}}
style={{ paddingLeft: 0 }}
key={i}
leftAvatar={{ source: { uri: l.avatar } }}
title={l.subject}
subtitle={l.username}
badge={{ value: l.count, textStyle: { color: 'white' } , badgeStyle: { backgroundColor: '#333', padding:8 } }} }
chevron
/>
))
它被溶解
badge={l.count !== 0 ? { value: l.count, textStyle: { color: 'white' } , badgeStyle: { backgroundColor: '#333', padding:8 } } : null}
您可以做:
badge={ l.count>0? { value: l.count, textStyle: { color: 'white' } , badgeStyle: { backgroundColor: '#333', padding:8 } }} : null }