我想将一系列本地图像文件发送到组件,以便可以渲染它们。 在图像来自本地存储的地方,我还没有找到任何办法。我只在图像具有在线链接的地方看到过这些链接,这些链接存储在一个对象中,然后将它们从中拉出。 有没有一种方法可以在一个对象中存储多个位置,然后将其发送到组件?
Product.Component.js
const Product = ({ image }) => {
return (
<View style={styles.container}>
<Text></Text>
<View>
<Image
style={{ width: 225, height: 225 }}
source={image}
/>
</View>
<View style={styles.button}>
</View>
</View>
)
}
App.js
import Product from './components/Product.Component'
import {Image} from 'react-native';
export default class App extends React.Component {
render() {
return (
<Container style={styles.container} >
<Product
style={{ width: 225, height: 225 } }
<Image source={require('./assets/images/logo/myimage.png')}/>
/>
</Container >
);
}
答案 0 :(得分:0)
import MyImage from './assets/images/logo/myimage.png'
<Image source={MyImage}/>