【问题标题】:react native : How to increase the font?react native:如何增加字体?
【发布时间】:2021-12-27 08:14:56
【问题描述】:

在我的示例中,我想增加变量的字体 增加elem.Sampling_Method_Code的字体的方法是什么 在我的情况下?

var digumMethods = '';
    execDetailData.forEach((elem) => {
      digumMethods = digumMethods + '\n' + elem.Sampling_Method_Code + '\n' + elem.Parameters_String + '\n' +__________' + '\n';
    });

【问题讨论】:

    标签: javascript css reactjs react-native


    【解决方案1】:

    您可以嵌套 Text 元素 (sample)。

    import * as React from 'react';
    import { Text, View, StyleSheet } from 'react-native';
    import Constants from 'expo-constants';
    
    export default function App() {
      return (
        <View style={styles.container}>
          <Text style={styles.smallText}>
            Small text <Text style={styles.bigText}>Bigger text</Text> Small Text
          </Text>
        </View>
      );
    }
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        justifyContent: 'center',
        paddingTop: Constants.statusBarHeight,
        backgroundColor: '#ecf0f1',
        padding: 8,
      },
      smallText: {
        margin: 24,
        fontSize: 18,
        fontWeight: 'bold',
        textAlign: 'center',
        color: '#ff0000'
      },
      bigText: {
        margin: 24,
        fontSize: 38,
        fontWeight: 'bold',
        textAlign: 'center',
        color: '#000000'
      },
    });
    

    【讨论】:

    【解决方案2】:

    这个可以帮到你

    const bigTextElement = (text) => <Text style={{fontSize:20}}>{text}</Text>;
    
    var digumMethods = '';
        execDetailData.forEach((elem) => {
          digumMethods = bigTextElement(digumMethods) + '\n' + elem.Sampling_Method_Code + '\n' + elem.Parameters_String + '\n' +__________' + '\n';
        });
    

    【讨论】:

      猜你喜欢
      • 2021-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-22
      • 2016-12-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多