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