react-native - React Native 0.61 按钮样式的新方法是什么
解决方案
我刚刚检查了 react native Button
props,如果您不复制源代码并将其制作成您自己的组件,则无法为其添加样式,您可以在这里找到它node_modules/react-native/Libraries/Components/Button.js
。
我建议你使用TouchableOpacity
,这样你就可以做任何你想做的事情,如果没有必要使用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>
推荐阅读
- python - 我们可以在 Altair 中绘制图像数据吗?
- date - 我在库存项目中需要帮助
- angular - 如何在使用Angular routerLink中的查询字符串传递迭代器中的项目时对其进行序列化?
- php - 访问 JWT 有效负载变量(Slim 框架中的 tuupola)
- javascript - “this”,参数和变量类型问题
- project-reactor - 第一个元素有时不包含在 Flux.switchOnFirst 的第二个参数中?
- javascript - 当事件在父级中触发时,将值从 React 子级传递给父级组件?
- python - 将 dict 的 JSON 嵌套列表转换为 DataFrame
- django - django DRF 自定义权限:详细视图的视图级权限
- javascript - 将数组元素插入表格 JavaScript / 并防止随机数重复