我正在尝试使用 expo-image 中的图像组件显示图像。我尝试过使用 React-native 来使用图像组件,并使用该组件来显示图像,但我希望能够使用 Expo 提供的组件。
我似乎找不到我丢失的东西。这就是我所拥有的:
import { Image } from "expo-image";
import { useRef, useState } from "react";
import {
Dimensions,
StyleSheet,
Text,
useWindowDimensions,
View,
} from "react-native";
export function Page() {
return (
<View>
<Image
style={styles.image}
contentFit="contain"
transition={1000}
source={`../../assets/mockImages/image1.png`}
/>
</View>
);
}
const styles = StyleSheet.create({
image: {
width: 100,
height: 100,
flex: 1,
},
});
在处理本地图像时尝试使用
source={require('...')}
将其正确包含在捆绑包中:
<Image
source={require('../../assets/mockImages/image1.png')}
// other props
/>