2017-07-31 61 views
0

我使用反应原生v0.44.2的滚动视图,我想禁用拉来刷新,只生成我的意见的滚动,有没有另一种方式做到这一点滚动型?
我看了一些旧版本,我不知道最近是否放这个动画。所以我的代码如下:反应原生滚动视图禁用拉刷新

render() { 
    return (
     <View> 
     <ScrollView> 
      <View style={styles.box}> 

      </View> 
      <View style={styles.box}> 

      </View> 
      <View style={styles.box}> 

      </View> 
      <View style={styles.box}> 

      </View> 
      <View style={styles.box}> 

      </View> 
      <View style={styles.box}> 

      </View> 
     </ScrollView> 

     </View> 
    ); 
    } 
} 

和我的风格:

const styles = StyleSheet.create({ 

    box: { 
    backgroundColor: 'blue', 
    height: 300, 
    width: 200, 
    borderWidth: 5, 
    borderColor: 'red' 
    } 
}); 
+1

,我觉得如果你只是用滚动视图默认道具没有使用拉刷新,我有尝试你的代码,并拉来刷新已禁用 –

回答

0

这里我们能做的是,我们可以利用这个Dissable上抠抠动画。

<ScrollView 
refreshing={false} 
> 
**YOUR RENDER ITEM** 
</ScrollView> 

我从来没有执行这个滚动视图上,但可能是它可以帮助你

+0

我都试过,但我真的不工作! –

1

使用一个const清爽=假,最初。然后在调用_onRefresh时,将false从false更改为true,并重新初始化scollview的内容。

const refreshing = false ; 
const data= []; 

//your class definition 
_onRefresh(){ 
     refreshing=true; 
     this.props.clearYourData(); 
     data= []; 
     refreshing=false; 
    } 

render(){ 
    return (
    <ScrollView refreshControl={ 
     <RefreshControl 
     refreshing={refreshing} 
     onRefresh={this._onRefresh.bind(this)} 
     title="Loading..." 
     /> 
     } 
     /> > 
    {data} 
    </ScrollView>) 
}