React-Native,滚动视图不滚动 [英] React-Native, Scroll View Not Scrolling

查看:96
本文介绍了React-Native,滚动视图不滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我像下面这个例子那样包装内容时,它完美地滚动..

When I wrap content like this example below, it scrolls Perfectly..

return(
    <ScrollView>
        <Text> TEST </Text>
        <Text> TEST </Text>
        <Text> TEST </Text>
        <Text> TEST </Text>
        ...
    </ScrollView>
);

但是,每当我将其包装在另一个 View 中时,它都不会滚动.

However, whenever I wrap it in another View, It will not scroll.

return(
    <View>
        <ScrollView>
            <Text> TEST </Text>
            <Text> TEST </Text>
            <Text> TEST </Text>
            <Text> TEST </Text>
            ...    
        </SCrollView>
    </View>
);

有没有办法解决这个问题.我试图在所有内容上方放置一个导航栏标题,但无法真正弄清楚.

Is there some sort of fix to this. I am trying to put a nav bar header above all of the content, couldn't really figure it out though.

推荐答案

这是一个错字:
您的 ScrollView 结束标记是:</SCrollView> 而不是 </ScrollView>.您还需要向 View 容器添加样式,下面是它应该是什么样子的示例:

It's a typo:
Your closing ScrollView tag is: </SCrollView> rather than </ScrollView>. You also need to add a style to the View container, here's an example of what it should look like:

return(
  <View style={{flex: 1}}>
    <ScrollView>
      <Text> TEST </Text>
      <Text> TEST </Text>
      <Text> TEST </Text>
      <Text> TEST </Text>
      ...    
    </ScrollView>
  </View>
);

这篇关于React-Native,滚动视图不滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆