作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 horizontal
FlatList 的渲染项上使用屏幕的宽度。但是,它没有按预期工作。当 horizontal
为 false 时,百分比值有效。但是当 horizontal
为真时,百分比值不起作用。
class App extends React.Component {
_renderItem = ({ item }) => {
return (
<View
style={{
width: '100%',
height: 100,
}}>
<Text>{item.key}</Text>
</View>
);
};
render() {
return (
<View style={styles.container}>
<FlatList
data={[{ key: 1 }, { key: 2 }, { key: 3 }]}
renderItem={this._renderItem}
horizontal={true}
/>
</View>
);
}
}
最佳答案
我想我记得有人提到过类似的事情。使用维度在这里有效。见这里:https://snack.expo.io/H1-wnC5HM
我宁愿用 flex 或百分比来解决它,但很好。
关于react-native - 当水平为真时,百分比不适用于 FlatList 渲染项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48477479/
我是一名优秀的程序员,十分优秀!