小编Mar*_*ome的帖子

如何将样式应用于每个ListItem Native-base

我有一个数组:

const routes = [
  { id: 1, title: 'Home', image: 'home', cstyle: 'styles.ItemsDrawer' },
  { id: 2, title: 'Chat', image: 'flask', cstyle: 'styles.ItemsDrawer' },
  { id: 3, title: 'Profile', image: 'briefcase', cstyle: 'styles.ItemsDrawer' },
  { id: 5, title: 'Logout', image: 'log-out', cstyle: 'styles.logout' }
];
Run Code Online (Sandbox Code Playgroud)

并希望应用于某些款式不同的款式,

<List dataArray={routes}
   renderRow={(data) =>
   <ListItem style={data.cstyle} 
     button onPress={() => ctx.navigate(data.title)} icon> 
   </ListItem>}>
</List>
Run Code Online (Sandbox Code Playgroud)

但我认为传递"data.cstyle"它会采取一个名称,并尝试在节样式表中找到它的样式,但这不能识别并保留没有样式到列表动态的每个项目

或者如何将不同的样式应用于列表中的某些项目

react-native-android native-base react-native-ios

1
推荐指数
1
解决办法
1740
查看次数