首页 > 解决方案 > 我的文本和视图样式表样式无法呈现,但是框屏幕文本内容显示了我错过的任何内容?

问题描述

我的样式TextView样式表样式无法呈现,但是框屏幕文本内容正在显示。我错过了什么?

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;

标签: javascriptnode.jsreact-native

解决方案


您正在添加道具样式而不是style道具,只需将样式重命名为style,下面是一个工作代码。

const BoxScreen = () => {
return( 
  <View style = {styles.viewStyle}>
     <Text style = {styles.textStyle}>Boxs screen</Text>
  </View>
);
};

这是您的代码样式示例。 世博小吃


推荐阅读