react-native - 使用 ImageBackground 时反应本机错误代码 500
问题描述
我正在学习本机反应,我的代码有错误
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"
}
});
并且此错误 在此处输入图像描述
在我的源中放置文件夹图像 在 此处输入图像描述
解决方案
关闭捆绑器,删除您的node_modules
,重新安装所有内容npm i
,然后再次启动捆绑器。那应该可以解决您的问题。
推荐阅读
- c - C - 读取文件时的无限循环
- react-native - 在 React Native 中卸载应用程序时,我可以捕获事件吗?
- php - 除了@yahoo 帐户之外,所有发件人都收到了 PHP 联系表格
- asp.net - URLEncode 在浏览器 MVC 中不起作用
- php - 尝试更新重复列的行时的 MySQL PHP 语法
- tfs - 您可以将迭代映射到 TFS 板上的列吗?
- swift - 将数据从 NSViewController 传递到 NSSplitViewController 中的另一个 NSViewController?
- java - 使用函数接口抽象公共代码的问题
- javascript - 如果属性值为 false,则保留扩展样式组件的默认值
- ios - OpentTok (iOS) 如何订阅 hasAudio 流的变化