2

我很确定我正在按照说明使用它,但文字没有改变:

import React, { Component } from "react";
import { StyleSheet, View } from "react-native";
import { ThemeProvider, Text } from "react-native-elements";
import Customer from "../models/Customer";

class CustomerScreen extends Component {
  render() {
    return (
      <View style={styles.container}>
        <ThemeProvider theme={theme}>
          <Text h1>{customer.fullName}</Text>
          <Text>{customer.email}</Text>
          <Text>{customer.phone}</Text>
        </ThemeProvider>
      </View>
    );
  }
}

const styles = {
  container: {
    flex: 1,
    marginTop: 50,
    marginLeft: 20,
    justifyContent: "flex-start",
    alignItems: "flex-start"
  }
};

const theme = {
  Text: {
    color: "red"
  }
};

export default CustomerScreen;

我究竟做错了什么??

4

1 回答 1

3

我通过style像这样嵌套它来让它工作:

const theme = {
  Text: {
    style: {
      color: "red"
    }
  }
};

我不是很熟悉,<ThemeProvider>它的文档并没有清楚地表明<Text>样式应该在style道具之下。您可能需要进一步试验它。:)

于 2019-06-11T15:38:57.550 回答