【问题标题】:react native error code 500 when use ImageBackground使用 ImageBackground 时反应本机错误代码 500
【发布时间】:2019-03-12 04:11:12
【问题描述】:

我正在学习 react native 并且有一个错误 这是我的代码

import React, {Component} from 'react';
import {View, ImageBackground, StyleSheet, Text} from 'react-native';

export default class Welcome extends Component{
    render() {
        return (
        <ImageBackground  source={require('./Image_app/welcome.jpg')}  style={styles.container} >
          <View style={styles.container}>
             <Text style={styles.headerText}>
               Setting background image in react native application
             </Text>
          </View>
        </ImageBackground>
        );
      }
    }

const styles = StyleSheet.create({
    container: {
    flex: 1,
    justifyContent: "center",
    alignItems: 'center',
    width: null,
    height: null,
    },
    headerText: {
    fontSize: 24,
    textAlign: "center",
    margin: 10,
    color: "white",
    fontWeight: "bold"
    }
});

还有这个错误 enter image description here

我的源中的放置文件夹图像 enter image description here

【问题讨论】:

  • 您能分享一下您在终端中遇到的错误吗?
  • 模块未在图中注册:D:\APK\React_Project\src\Image_app\welcome.jpg
  • 刚刚添加了一个答案,检查是否有效,如果有效,请接受答案。

标签: react-native


【解决方案1】:

关闭捆绑器,删除您的node_modules,重新安装npm i 的所有内容,然后重新启动捆绑器。这应该可以解决您的问题。

【讨论】:

    猜你喜欢
    • 2023-02-02
    • 2016-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-04
    • 2020-05-14
    • 2021-12-18
    相关资源
    最近更新 更多