mirror of
https://github.com/wu736139669/RN_AWord.git
synced 2026-08-05 06:24:39 +00:00
优化listview
This commit is contained in:
+1
-3
@@ -119,8 +119,6 @@ getInitialState: function() {
|
||||
);
|
||||
},
|
||||
pushInfo:function(index){
|
||||
console.log(this.state.dataSource.getRowData(0,index))
|
||||
|
||||
this.props.navigator.push({
|
||||
title: 'New Page',
|
||||
component: <InfoPage movie={this.state.dataSource.getRowData(0,index)}> </InfoPage>
|
||||
@@ -129,7 +127,7 @@ getInitialState: function() {
|
||||
renderLoadingView:function(){
|
||||
if (!this.state.isLoadingFail) {
|
||||
return (
|
||||
<TouchableOpacity onPress={() =>this.fetchData()} style={styles.container} >
|
||||
<TouchableOpacity onPress={() =>this.fetchData} style={styles.container} >
|
||||
<View style={styles.container}>
|
||||
<Text>
|
||||
{'点击刷新'}
|
||||
|
||||
+4
-6
@@ -60,8 +60,6 @@ export default class MyListView extends Component{
|
||||
myfetchData(){
|
||||
this.setState({isLoading:true,isLoadingFail:false});
|
||||
this.props.fetchData().then((responseData)=>{
|
||||
console.log('接受到数据');
|
||||
console.log(responseData);
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
isLoadingFail: false,
|
||||
@@ -104,13 +102,13 @@ export default class MyListView extends Component{
|
||||
pushInfo(index){
|
||||
this.props.navigator.push({
|
||||
title: 'New Page',
|
||||
component: <InfoPage movie={this.state.dataSource.getRowData(0,index)}> </InfoPage>
|
||||
}).bind(this);
|
||||
component: <InfoPage movie={this.props.dataSource.getRowData(0,index)}> </InfoPage>
|
||||
});
|
||||
}
|
||||
renderLoadingView(){
|
||||
if (this.state.isLoadingFail) {
|
||||
return (
|
||||
<TouchableOpacity onPress={() =>this.myfetchData.bind(this)} style={styles.container} >
|
||||
<TouchableOpacity onPress={() =>this.myfetchData()} style={styles.container} >
|
||||
<View style={styles.container}>
|
||||
<Text>
|
||||
{'点击刷新'}
|
||||
@@ -141,7 +139,7 @@ export default class MyListView extends Component{
|
||||
return (
|
||||
|
||||
<View style={styles.container} key={rowID}>
|
||||
<TouchableOpacity onPress={(rowID) =>this.pushInfo.bind(this)} style={styles.container} >
|
||||
<TouchableOpacity onPress={()=>{this.pushInfo(rowID)}} style={styles.container} >
|
||||
<Image
|
||||
source={{uri: movie.imageurl}}
|
||||
style={styles.thumbnail}/>
|
||||
|
||||
+3
-6
@@ -39,10 +39,7 @@ export default class MyListViewDemo extends Component{
|
||||
<Text style={styles.title}>
|
||||
随机
|
||||
</Text>
|
||||
),
|
||||
event: function() {
|
||||
this.fetchData();
|
||||
}.bind(this)
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -59,7 +56,7 @@ export default class MyListViewDemo extends Component{
|
||||
fetch(url)
|
||||
.then((response) => response.json())
|
||||
.catch((error) => {
|
||||
reject(err);
|
||||
reject(error);
|
||||
})
|
||||
.then((responseData) => {
|
||||
if(responseData){
|
||||
@@ -82,7 +79,7 @@ export default class MyListViewDemo extends Component{
|
||||
<MyListView
|
||||
dataSource={this.state.dataSource}
|
||||
refreshTitle={'测试一下刷新'}
|
||||
navigator={this.props.navigator}
|
||||
{...this.props}
|
||||
fetchData={this.fetchData.bind(this)}/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,6 @@ class TabBarNavigator extends Component {
|
||||
};
|
||||
}
|
||||
setNavItems(config) {
|
||||
console.log('setting nav items. currentTabIndex: ' + this.currentTabIndex);
|
||||
if (this.currentRoute.isRoot) {
|
||||
this.rootNavigatorItems[this.state.currentTabIndex] = config;
|
||||
this.forceUpdate();
|
||||
|
||||
Reference in New Issue
Block a user