在我的react原生项目中,没有显示背景图像



在应用程序文件夹中,我有两个文件夹屏幕和资产,我给出了正确的路径,但背景图像没有应用于模拟器。

import React from "react";
import {
ImageBackground,
Platform,
StyleSheet,
Text,
View,
} from "react-native";
const image = { uri: "https://reactjs.org/logo-og.png" };
const WelcomeScreen = () => (
<ImageBackground
style={styles.background}
source={require("../assets/background.jpg")}
>
<View style={styles.loginButton}></View>
</ImageBackground>
);
const styles = StyleSheet.create({
background: {
top: 0,
right: 0,
bottom: 0,
left: 0,
position: "absolute",
},
loginButton: {
width: "100%",
height: 70,
backgroundColor: "#fc5c65",
},
});
export default WelcomeScreen;

这里我使用样式表,但不工作我需要你们的帮助,伙计们,好心地帮助

提前感谢

你能把一个height放在背景样式中并尝试一次吗?我认为ImageBackground要求一个高度,如果没有给出的话。

ref-ImageBackground获胜';t出现

最新更新