我正试图为我的组成员的配置文件屏幕.我的想法是使四个屏幕使用路由参数设置所有信息只有一种字体,像这样:
<TouchableOpacity style={styles.ident1} onPress={() => navigation.navigate('Profile', {
Nome: 'Ângelo J. da Rosa', Resto: ['19 Anos', 'Cocal do Sul - SC'], Foto: '../../assets/angelo.jpeg'
})}>
<Text style={{ fontSize: 20,fontWeight: 'bold' }}>Angelo</Text>
</TouchableOpacity>
字符串
但是,当我试图从文件夹中使用的路径,我从paramns(照片)得到的图像,我得到一个错误,不知道如何进行
我的屏幕字体:
import React from 'react';
import { View, Text, Image, StyleSheet } from 'react-native';
export default function Profile({ route, navigation }) {
const { Nome, Resto, Foto } = route.params;
return (
<View style={styles.container}>
<Image
style={styles.image}
source={require({Foto})}
/>
<Text style={[styles.headline]}>{"\n"}{Nome}</Text>
<View style={[styles.views, styles.ident1]}>,
<Text style={[styles.desc]}>{Resto[0]}</Text>
<Text style={[styles.desc]}>{Resto[1]}</Text>
<Text style={[styles.desc]}>{Resto[2]}</Text>
<Text style={[styles.desc]}>{Resto[3]}</Text>
<Text style={[styles.desc]}>{Resto[4]}</Text>
</View>
</View>
)
};
型
1条答案
按热度按时间vatpfxk51#
你在传递图像路径时犯了一个错误。你可以按照下面的代码:
字符串
把它当作 prop ,像这样:
型
注:有关更多信息,请参阅:Load image passed as props react native