Android Can';找不到映像的相对/本地目录-反应本机
我正在尝试显示计算机文件中的图像。然而,它不会出现。我做了一点调试,发现当我将目录设置为:Android Can';找不到映像的相对/本地目录-反应本机,android,ios,reactjs,react-native,Android,Ios,Reactjs,React Native,我正在尝试显示计算机文件中的图像。然而,它不会出现。我做了一点调试,发现当我将目录设置为: source={{uri:'http://www.telegraph.co.uk/content/dam/Travel/galleries/travel/activityandadventure/The-worlds-most-beautiful-mountains/mountains-fitzroy_3374108a.jpg'}} 它在屏幕中央显示我想要的图像。我不想使用网络地址,我想使用相对
source={{uri:'http://www.telegraph.co.uk/content/dam/Travel/galleries/travel/activityandadventure/The-worlds-most-beautiful-mountains/mountains-fitzroy_3374108a.jpg'}}
它在屏幕中央显示我想要的图像。我不想使用网络地址,我想使用相对地址。所以我用这个:
source={{uri:'/./pictures/m.jpg'}}
当我这样做时,它显示为没有图像或错误。
如何使图像显示在相对目录中?
以下是我的全部代码:
import React, { Component } from 'react';
import { Button,Alert, TouchableOpacity,Image, Dimensions } from 'react-native'
import {
AppRegistry,
StyleSheet,
Text,
View,
} from 'react-native';
class Project extends Component {
render() {
return (
<View style={{backgroundColor: '#375D81', flex: 1}}>
<View style = {styles.container}>
<Image source={{uri: './pictures/Blur.png/'}} style={{ resizeMode: 'cover', width: 100, height: 100 }}/>
<TouchableOpacity style = {styles.buttonText1} onPress={() => { Alert.alert('You tapped the button!')}}>
<Text style={styles.text}>
Button 1
</Text>
</TouchableOpacity>
<TouchableOpacity style = {styles.buttonText2} onPress={() => { Alert.alert('You tapped the button!')}}>
<Text style= {styles.text}>
Button 2
</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
import React,{Component}来自'React';
从“react native”导入{按钮、警报、TouchableOpacity、图像、维度}
进口{
评估学,
样式表,
文本,
看法
}从“反应本机”;
类项目扩展组件{
render(){
返回(
{Alert.Alert('你点击了按钮!')}>
按钮1
{Alert.Alert('你点击了按钮!')}>
按钮2
);
}
}
以下是我的文件夹:
提前感谢。使用本地目录时,最好使用
require
功能,例如:
<Image source={{require('./pictures/Blur.png/')}} style={{ resizeMode: 'cover', width: 100, height: 100 }}/>