组件的resizeMode不管设置stretch还是cover,都无法显示出全部图片,图片顶部和底部都有遮挡
在放大组件高度后,观察到了图片的顶部和底部了。
最后通过:https://stackoverflow.com/questions/39631895/how-to-set-image-width-to-be-100-and-height-to-be-auto-in-react-native
设置了style中属性aspectRatio: image.width / image.height
最终组件:
<Image
resizeMode={'stretch'}
style={{
aspectRatio: getDeviceValue(1884) / getDeviceValueByHeight(85),
width: getDeviceValue(1884),
// height: null,
alignSelf: 'center',
position: 'absolute',
}}
source={xxxx}
/>