Blockquote
code
<Text style ={styles.header}>
Flex
</Text>
header: {
justifyContent: 'center',
alignSelf: 'center',
fontWeight: 'bold',
marginTop: 55,
color: 'red',
}
问题color属性没有改变,Text的所有属性都在起作用,而不是color
像这样更改style
:
<Text h1 style={styles.header}>
应该工作
您需要使用style
而不是h1style
。由于没有名为h1style
的道具。请参考下面的代码
import React, { Component } from "react";
import { StyleSheet, Text } from "react-native";
class App extends Component {
render() {
return (
<Text h1 style={styles.header}>
Flex
</Text>
);
}
}
const styles = StyleSheet.create({
header:
justifyContent: "center",
alignSelf: "center",
fontWeight: "bold",
marginTop: 55,
color: "#13E5F5"
}
});
export default App;
[更多的帮助,请在线检查codesandbox上的相同代码
h1style
在react native中不是有效的道具名称。您需要使用style
而不是h1style
。
<Text h1 style={styles.header}>