【问题标题】:Need help in react native in text section需要帮助在文本部分做出本机反应
【发布时间】:2021-12-10 20:49:28
【问题描述】:

'我的问题是关于 react native' “我正在尝试更改颜色和字体大小 Hello、world 和 Hello,但它没有改变,代码运行良好。” '''

import { StatusBar } from 'expo-status-bar';
    import React from 'react';
    import { StyleSheet, Text, View } from 'react-native';
    
    export default function App() {
      return (
        <View style={styles.container}>
          <Text style={[styles.Red,styles.One]}>Praveen</Text>
          <Text Style={[styles.White,styles.Two]}>
            Hello, World
            </Text>
            <Text H1>Hello</Text>
          <StatusBar style="auto" />
        </View>
      );
    }
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        backgroundColor: '#FFFFFF',
        alignItems: 'center',
        justifyContent: 'center',
      },
      Red: {
        color: '#F44336'
    
      },
      One: {
        fontSize : 80
      },
      White: {
        color : '#F44336'
      },
      Two: {
        fontSize : 80
      },
    }); 

'''

【问题讨论】:

  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: html css reactjs react-native


【解决方案1】:

您使用大写字母 s 而不是 style 编写了 Style,道具区分大小写,因此请确保使用正确的命名

代码应如下所示:

import { StatusBar } from 'expo-status-bar';
    import React from 'react';
    import { StyleSheet, Text, View } from 'react-native';
    
    export default function App() {
      return (
        <View style={styles.container}>
          <Text style={[styles.Red,styles.One]}>Praveen</Text>
          <Text style={[styles.White,styles.Two]}>
            Hello, World
            </Text>
            <Text H1>Hello</Text>
          <StatusBar style="auto" />
        </View>
      );
    }
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        backgroundColor: '#FFFFFF',
        alignItems: 'center',
        justifyContent: 'center',
      },
      Red: {
        color: '#F44336'
    
      },
      One: {
        fontSize : 80
      },
      White: {
        color : '#F44336'
      },
      Two: {
        fontSize : 80
      },
    });

【讨论】:

  • 感谢哥们,它现在可以工作了
猜你喜欢
  • 2013-10-05
  • 2020-10-13
  • 2016-03-01
  • 2022-06-15
  • 2013-06-21
  • 2019-12-08
  • 1970-01-01
  • 1970-01-01
  • 2018-08-08
相关资源
最近更新 更多