javascript - 我的文本和视图样式表样式无法呈现,但是框屏幕文本内容显示了我错过的任何内容?
问题描述
我的样式Text
和View
样式表样式无法呈现,但是框屏幕文本内容正在显示。我错过了什么?
import React from "react";
import { Text, StyleSheet, View} from "react-native";
const BoxScreen = () => {
return(
<View styles = {styles.viewStyle}>
<Text styles = {styles.textStyle}>Boxs screen</Text>
</View>
);
};
const styles = StyleSheet.create({
viewStyle: {
borderWidth: 3,
borderColor: 'black'
},
textStyle: {
borderWidth: 1,
borderColor: 'red',
marginVertical: 20
}
});
export default BoxScreen;
解决方案
您正在添加道具样式而不是style
道具,只需将样式重命名为style
,下面是一个工作代码。
const BoxScreen = () => {
return(
<View style = {styles.viewStyle}>
<Text style = {styles.textStyle}>Boxs screen</Text>
</View>
);
};
这是您的代码样式示例。 世博小吃
推荐阅读
- php - PDO 错误:SQLSTATE[HY093]:无效的参数号:绑定变量的数量与标记的数量不匹配
- python - Django如何将请求函数中的值导入函数?
- swift - 变量始终为零(可编码)
- c - Arm7 Timer0 中断仅在模拟中完美运行
- python - 如何在python中并排获得两个图表?
- php - 正则表达式:如何添加捕获组?
- python - RuntimeError: There is no current event loop in thread ... DiscordPy MultiThreading
- html - 有人知道如何在不从中心丢失标题的情况下放大全屏标题栏吗
- acumatica - 提供超链接栏不打开formview
- c++ - 在 C++ 中映射多对