我有一个基于 Expo 的 React Native 项目。我需要在屏幕上查看图像,其样式基于该图像的宽度和高度。我怎样才能得到该图像的宽度和高度?
假设图像 uri 是file:///storage/emulated/0/WhatsApp/Media/WhatsApp%20Images/IMG-20200117-WA0019.jpg
带有代码示例的解决方案受到高度赞赏。
我需要知道如何将 props 的默认值设置为 React Native。我有以下代码:
<View style={{ ...styles.textBox, ...props.bg }}>
<Text style={{ ...styles.pretitle, ...props.style }}>{props.pretitle}</Text>
<Text style={{ ...styles.title, ...props.style2 }}>{props.title}</Text>
<Text style={styles.introduction}>{{ '', ...props.introduction }}</Text>
</View>
Run Code Online (Sandbox Code Playgroud)
如果props.introduction是0我想将它设置为空,如:“”,或者有一些其他的价值,比如:“未设置”。
谢谢