gpt4 book ai didi

javascript - 无法在 React Native 中滚动到 ScrollView 的底部

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:51:36 25 4
gpt4 key购买 nike

我有一个使用 ScrollView 的非常简单的示例,但我似乎无法滚动到底部。

这个例子是完全基础的,我没有做任何特别的事情,但最后一项永远不会完全可见。

Expo Code

 import React, { Component } from "react";
import { Text, View, ScrollView, StyleSheet } from "react-native";
import { Constants } from "expo";

const data = Array.from({ length: 20 }).map((_, i) => i + 1);

export default class App extends Component {
render() {
return (
<ScrollView style={styles.container}>
{data.map(d => (
<View style={styles.view}>
<Text style={styles.text}>{d}</Text>
</View>
))}
</ScrollView>
);
}
}

const styles = StyleSheet.create({
container: {
paddingTop: Constants.statusBarHeight
},
text: {
fontWeight: "bold",
color: "#fff",
textAlign: "center",
fontSize: 28
},
view: {
padding: 10,
backgroundColor: "#018bbc"
}
});

这是输出:

output image

最佳答案

将填充样式应用于“contentContainerStyle”属性,而不是 ScrollView 的“style”属性。

关于javascript - 无法在 React Native 中滚动到 ScrollView 的底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45132731/

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