【发布时间】:2021-05-23 21:10:15
【问题描述】:
我是 React Native 的初学者,我想在其中编写第一行代码。我做了一个按钮,开始想知道如何更改按钮中文本的颜色和其他属性。
<Button title="Click Me"></Button>
我还想知道是否有一些推荐给初学者的好包。感谢您的帮助。
【问题讨论】:
标签: android ios reactjs react-native mobile
我是 React Native 的初学者,我想在其中编写第一行代码。我做了一个按钮,开始想知道如何更改按钮中文本的颜色和其他属性。
<Button title="Click Me"></Button>
我还想知道是否有一些推荐给初学者的好包。感谢您的帮助。
【问题讨论】:
标签: android ios reactjs react-native mobile
您可以像这样使用 react-native 中的 Button,也可以传递 color 属性。
Button
onPress={onPressLearnMore}
title="Click Me"
color="#841584"
/>
对于复杂和自定义按钮,您可以使用 react-native 提供的 Touchables 以您自己的样式创建它,您不必为此使用任何第三方库。
例子:
<TouchableOpacity style={{ here you can specify custom styles for button container }} onPress={gotoDashboard}>
<Text style={{here you can specify text styles}}>Button Text Here</Text>
// You can add there as many components according to your designs.
</TouchableOpacity>
【讨论】: