[英]how can I use Image in react native?
I want to use image uri and render my Image but it doesn't show up I don't know why我想使用图像 uri 并渲染我的图像,但它没有显示我不知道为什么
here is my code hi I'm using react-native这是我的代码嗨我正在使用 react-native
I want to use image uri and render my Image but it doesn't show up I don't know why我想使用图像 uri 并渲染我的图像,但它没有显示我不知道为什么
here is my code这是我的代码
import React from 'react';
import styled from 'styled-components/native';
import {FlatList,
Dimensions,
ScrollView,
NativeSyntheticEvent,
NativeScrollEvent,
} from 'react-native';
import {useSelector,useDispatch} from 'react-redux';
const Container = styled.View`
`;
const Hey = styled.Text`
`;
const ImageContainer = styled.View`
border-top-width: 1px;
border-bottom-width: 1px;
border-color: #D3D3D3;
width: ${Dimensions.get('window').width}px;
height: 400px;
/* background: lightgray; */
`;
const ImageStyle = styled.Image`
`;
const Food = ({navigation}) => {
const {cookUp} = useSelector((state) => state.post);
console.log("cookUp:",cookUp);
return (
<>
{cookUp.length ? (
<FlatList
data={cookUp}
keyExtractor={(item) => String(item.id)}
// keyExtractor={(item, index) => {
// return `${index}`;
// }}
renderItem={({item}) => (
console.log("item.Images:",item.Images),
<ImageContainer>
<ImageStyle
source={{uri:item.Images[0].src}}
/>
</ImageContainer>
)}
/>
) :
(<Hey>hiaaaaaa</Hey>)
}
</>
);
};
export default Food;
and this is console log这是控制台日志
how can I fix my code?如何修复我的代码? can you please help me??你能帮我么??
Try this way试试这个方法
import {Image} from 'react-native';
<Image
source={{uri:item.Images[0].src}}
width={200}
height={200}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.