我正在尝试使用React-native更改按钮的背景颜色。
我无法弄清楚为什么会这样
<Button
color="#841584"
title={item.title}
/>
但事实并非如此
<Button
style={styles.buttonStyle}
color="#841584"
title={item.title}
/>
const styles = StyleSheet.create({
buttonStyle: {
color:"#841584"
}
});
我尝试使用color
或backgroundColor
属性,但它们都不起作用
为什么这些彼此不同?
反应原生的Button
成分没有style
道具。因此,您提供的风格不适用。
道具
- onPress
- 标题
- accessibilityLabel
- 颜色
- 残
- 测试
- hasTVPreferredFocus
它基本上是一个内置于react-native的自定义组件。你可以使用TouchableOpacity
或TouchableNativeFeedback
创建你的。为了获得灵感,你可以看看source code for Button
component。