Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 如何在react native中显示来自后端的图像_React Native_React Native Android - Fatal编程技术网

React native 如何在react native中显示来自后端的图像

React native 如何在react native中显示来自后端的图像,react-native,react-native-android,React Native,React Native Android,我是新来的,请帮帮我。我上传了我的产品图片,然后把它们的链接放到mysql工作台上。然后我得到了这样的信息: ''' 导出默认类。组件{ _isMounted = false; state = { Data: [], itemcolor: '#ff4500', }; async componentDidMount() { this._isMounted = true; const a = await axios.get('http://192.1

我是新来的,请帮帮我。我上传了我的产品图片,然后把它们的链接放到mysql工作台上。然后我得到了这样的信息: ''' 导出默认类。组件{

_isMounted = false;

state = {
    Data: [],
    itemcolor: '#ff4500',
    
};



async componentDidMount() {
    this._isMounted = true;
    const a = await axios.get('http://192.168.43.43/api/dreams/pizza');
    if (this._isMounted) {
        this.setState({ Data: a.data });
    }
    //alert({ state.Data.data[1].pizzaTitle });
    //alert(JSON.stringify(a))
    //alert(this.state.Data[0].pizzaTitle)
}
componentWillUnmount() {
    this._isMounted = false;
}'''
然后使用映射函数尝试显示它们: ''render(){

返回(
{
this.state.Data.map(项=>(
{

警报(“你按了按钮!”);
console.log(item.pizzaimg);
}}
style={style.touch}
>
{item.pizzaTitle}
{item.pizzaPrice}
))
}
)
};
};
''' 现在我不知道如何从后端链接以touchableopacity显示我的图像。我如何才能做到这一点?

只需使用
    return (<View style={styles.container}>
        <ScrollView>
            {
                this.state.Data.map(item => (
                    <View key={item.id}>

                        <TouchableOpacity
                            onPress={() => {
                                < Child text={item.pizzaTitle} />
                                alert('You tapped the button!');
                                console.log(item.pizzaimg);
                            }}
                            style={styles.touch}
                        >
                            <Text style={styles.text}>{item.pizzaTitle}</Text>
                            <Text style={styles.textp}>{item.pizzaPrice}</Text>                             
                                                            
                        </TouchableOpacity>
                        
                        
                        
                    </View>
                    ))
            }
        </ScrollView>                      
        
    </View>)

    };

};