FlatList似乎不起作用.我收到了这个警告.
@H_
403_1@VirtualizedList:缺少项目的键,确保在每个项目上指定键
属性或提供
自定义keyExtractor.
@H_
403_1@码:
<FlatList
data={[{name: 'a'},{name: 'b'}]}
renderItem={
(item) => <Text key={Math.random().toString()}>{item.name}</Text>
}
key={Math.random().toString()} />
只需这样做:
<FlatList
data={[{name: 'a'},{name: 'b'}]}
renderItem={
(item) => <Text>{item.name}</Text>
}
keyExtractor={(item,index) => index}
/>
@H_
403_1@资料来源:
here
原文链接:https://www.f2er.com/react/301263.html