gpt4 book ai didi

javascript - React Native Scroll View 不滚动也不跳到底部

转载 作者:行者123 更新时间:2023-11-28 00:55:33 25 4
gpt4 key购买 nike

我是 React Native 的新手,我对 .滚动不适用于 ScrollView。

我尝试将“flex:1”赋值给 ,也尝试将它包裹起来,但没有用...

我已经尝试了多种提供“flex:1”来查看和 ScrollView 的解决方案,但似乎没有任何效果......

谁能帮我解决这个问题?此外,如果您能告诉我如何在向 scrollView 添加新内容时反弹/跳转到 scrollView 的底部,那将非常棒。

谢谢。

下面是我的代码:

<Container>
<Content style={{backgroundColor: 'white'}}>
<ScrollView contentContainerStyle={{ flex: 1 }}>
<View style={{flex: 1, flexDirection: 'column', alignItems: 'center', marginTop: 20, height: 555, }}>
<View
style={{
width: 80,
height: 80,
backgroundColor:'#959595',
borderRadius: 50,
}}
/>
<Text style={{fontWeight: 'bold', marginTop: 15}}>Personal Assistant</Text>

<View style={{flexDirection: 'row', marginTop: 25, marginLeft: 15}}>
<View
style={{
width: 50,
height: 50,
backgroundColor:'#E3E3E3',
borderRadius: 50,
}}
/>

<View style={{flex: 1, flexDirection: 'column', marginLeft: 15, marginRight: 15}}>
<View style={{backgroundColor: "#E3E3E3", borderRadius: 10, padding: 10}}>
<Text>
Hello{"\n"}
I'm your personal assistant to help you list your item. {"\n"}
Let's get started!
This will only take a minute.
</Text>

<Text style={{color: "#575757", marginTop: 10, fontSize: 12}}>35 mins ago</Text>
</View>

<View style={{backgroundColor: "#E3E3E3", borderRadius: 10, padding: 10, marginTop: 10}}>
<Text>
First of all, are you trying to {"\n"}SELL or open for BOTH?
</Text>

<Text style={{color: "#575757", marginTop: 10, fontSize: 12}}>35 mins ago</Text>
</View>
</View>
</View>

{
this.state.assistanceResponse >= 2 && this.registerDataObj["firstSelection"] !== null || undefined ?

<View style={{display: "flex", backgroundColor: "#3578e5", borderRadius: 10, padding: 10, alignSelf: 'flex-end', marginRight: 15, marginTop: 10}}>
<Text style={{color: 'white'}}>
{this.registerDataObj["firstSelection"].toUpperCase()}
</Text>

<Text style={{color: "white", marginTop: 10, fontSize: 12}}>35 mins ago</Text>
</View>

:
<React.Fragment></React.Fragment>
}

{
this.state.userResponse >= 2 ?
<View style={{flexDirection: 'row', marginTop: 10, marginLeft: -10 }}>
<View
style={{
width: 50,
height: 50,
backgroundColor:'#E3E3E3',
borderRadius: 50,
}}
/>
<View style={{backgroundColor: "#E3E3E3", borderRadius: 10, padding: 10, marginLeft: 15}}>
<Text>
Great! Which category of product {"\n"}
are you trying to {`${this.registerDataObj['firstSelection'].toUpperCase()}`}?
</Text>

<Text style={{color: "#575757", marginTop: 10, fontSize: 12}}>35 mins ago</Text>
</View>
</View>
:
<React.Fragment></React.Fragment>
}

{
this.state.assistanceResponse >= 3 && this.registerDataObj["categorySelection"] !== null || undefined ?

<View style={{display: "flex", backgroundColor: "#3578e5", borderRadius: 10, padding: 10, alignSelf: 'flex-end', marginRight: 15, marginTop: 10}}>
<Text style={{color: 'white'}}>
{this.registerDataObj["categorySelection"].toUpperCase()}
</Text>

<Text style={{color: "white", marginTop: 10, fontSize: 12}}>35 mins ago</Text>
</View>

:
<React.Fragment></React.Fragment>
}
</View>
</ScrollView>
</Content>
</Container>

最佳答案

您有没有使用过 Native Base?如果是,他们的 Content 组件实际上是一个 ScrollView。所以在你的情况下,你有 2x ScrollViews。我会删除 <ScrollView contentContainerStyle={{ flex: 1 }}> ,并且只有 <Container><Content><View style....

关于javascript - React Native Scroll View 不滚动也不跳到底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52958402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com