我正在創建一個銷售電子書的應用程式,在為每本書創建詳細資訊頁面時,我用滾動視圖包裹了整個組件,但它不起作用,您可以在附加的螢屏錄制中看到我的結果,我查看了許多解決方案,但是找不到解決我的問題的方法,
這是我的導致問題的組件的代碼:
import React, {useRef} from 'react';
import {StyleProp, ViewStyle} from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
interface HeaderLinearGradientProps {
height?: number | string;
styles?: StyleProp<ViewStyle> | any;
}
const HeaderLinearGradient: React.FC<HeaderLinearGradientProps> = ({
height,
children,
styles,
}) => {
const colors = useRef(['#4685EC', '#00296B']);
return (
<LinearGradient
colors={colors.current}
style={{
...styles,
height: height || '30%',
}}>
{children}
</LinearGradient>
);
};
export default HeaderLinearGradient;
這是我得到的結果 https://drive.google.com/file/d/121x2CNuj3M63aJu_Z1PjxYbYxivCrhuP/view?usp=sharing
任何幫助將不勝感激,謝謝
uj5u.com熱心網友回復:
你有沒有試過申請contentContainerStyle={{flexGrow: 1}}和container={{flex: 1}}?
似乎它應該可以解決問題??
uj5u.com熱心網友回復:
如何將滾動視圖組件包裝在如下所示的容器中
<View style = {{ flex : 1 }}>
<ScrollView contentContainerStyle = {{ flexGrow : 1 }}>
</ScrollView>
</View>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/367193.html
標籤:javascript 反应 反应原生
