这个旧的帖子谈到titleStyle
和textStyle
,但似乎不再基于道具:
如何将样式对象添加到按钮?现在我应该有一个自定义视图,而不是一些触摸卡巴比尔?我需要实现:
谢谢.
我刚刚检查了react native Button
props,如果你不复制源代码并将其放入自己的组件,你就无法在这里找到node_modules/react-native/Libraries/Components/Button.js
.
我建议您使用TouchableOpacity
,所以您可以做任何您想要的IF没有必要使用Button
.像这样:
<TouchableOpacity
disabled={disabled || disabledNoLoading}
style={[styles.buttonView, {
backgroundColor: disabled || disabledNoLoading ? disabledColor : backgroundColor,
width: buttonWidth,
marginTop,
borderColor
}]}
onPress={() => {Alert.alert('Pressed')}}
>
{
disabled ?
(<Text>Loading...</Text>)
: (<Text style={[styles.buttonText, {color: textColor}]}>{text}</Text>)
}
</TouchableOpacity>