1 回答
TA贡献1844条经验 获得超8个赞
答案是肯定可以的!
我想楼主的意思是想在一个组件上既显示一个ListView,还要显示一些其他的东西,比如图片,文本,具体代码参考如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import ReactNative from 'react-native';
import React, { Component } from 'react';
import styles from './styles';
const { View, Text, ScrollView, Image, ListView } = ReactNative;
class MyNewComponent extends Component {
constructor(props){
super(props);
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: ds.cloneWithRows(['hello', '1ffasdf', 'fasdfasd', 'Peter', '8799ffff','faddsffasd', 'afdafsdf', 'fasdfasdf',' afsdfasdfasd', 'a', 'b', 'c', 'd']),
}
}
render() {
return (
<View style={styles.container}>
<ScrollView>
<ListView
dataSource={this.state.dataSource}
renderRow={(rowData) => <Text>{rowData}</Text>}
style={{height: 100,}}
/>
<Text>Hello World</Text>
<Image source={require("../../images/user2.jpg")} />
<Image source={require("../../images/user2.jpg")} />
</ScrollView>
</View>
);
}
}
export default MyNewComponent;
- 1 回答
- 0 关注
- 963 浏览
添加回答
举报