运行 react-native run-ios 时出现整个黑屏 [英] Getting an entire black screen when running react-native run-ios

查看:41
本文介绍了运行 react-native run-ios 时出现整个黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行代码时,会生成一个 IOS 手机模拟器.该应用程序启动但会产生一个完整的黑屏.查看文本的唯一方法是更改​​文本的颜色.我的代码在底部.

When running the code an emulator for an IOS phone is produced. The application launches but produces an entire black screen. The only way to see the text is by changing the color of the text. My code is seen in the bottom.

import React from "react";
import { AppRegistry, Text } from "react-native";

const App = () => {
 return <Text style={{ color: "red" }}>Some Text</Text>;
};

AppRegistry.registerComponent("albums", () => App);

根据我的理解.初始默认值应为白色背景,文本应为黑色.希望有人能帮助我更好地了解问题可能是什么.这是我第一次尝试 React Native,尽管我确实有一些 React 经验.

From my understanding. The initial default should be a white background and the text should be in black. Hope someone can help me better understand what the issue might be. This is my first attempt with React Native although I do have some experience with React.

谢谢

推荐答案

你需要像这样在 View 中换行

You need to wrap text in a View like

<View style={{backgroundColor: 'white'}}>
  <Text style={{ color: "red" }}>Some Text</Text>
</View>

至于默认样式是白底黑字,如果你使用react-native-init或者Expo来生成项目就是这种情况.

As for the default style being black text on white background, that's the case if you use react-native-init or Expo to generate the project.

这篇关于运行 react-native run-ios 时出现整个黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆