【发布时间】:2017-11-12 03:54:28
【问题描述】:
我试图在我的 ListView 中查看项目“Pizza”,但出现错误。我查看了其他一些具有相同错误的 SO 帖子,但我无法找出问题所在。我们应该如何设置我的 ListView?我一直在关注这个guide 以供参考。我的代码如下:
class MyNewAppreactold extends Component {
constructor(props) {
super(props);
this.state = {
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
})
};
}
componentDidMount() {
this.setState({
dataSource: this.state.dataSource.cloneWithRows([{ title: 'Pizza' }])
})
}
_renderItem(item) {
return (
<ListItem item={item} />
// <ListItem item={item} onPress={onPress} />
// <ListItem item={item} onPress={() ==""> {}} />
);
}
render() {
return (
<View style={styles.container}>
<StatusBar title="Grocery List" />
<ListView datasource={this.state.dataSource}
renderrow={this._renderItem.bind(this)}
style={styles.listview}/>
<ActionButton title="Add" />
</View>
)
}
}
AppRegistry.registerComponent('MyNewAppreactold', () => MyNewAppreactold);
【问题讨论】:
-
你能在你的代码中像这样制作 renderRow 并检查
-
你使用的是renderrow,都是小写的。您可以像上面那样尝试并检查
-
@SivajeeBattina 我尝试了 renderRow。仍然出现同样的错误。
标签: javascript android ios listview react-native