我在更改自定義組件的一些特定匯入的文本顏色時遇到問題。
當我通過更改使用它的道具的值來匯入它時,我可以根據它的使用來更改按鈕本身的邊框顏色和背景顏色。但是我不知道如何對文本做同樣的事情。我想它是微不足道的,但任何幫助將不勝感激。
下面的代碼是按鈕的代碼。
import React from 'react';
import { StyleSheet, Text, TouchableOpacity } from 'react-native';
import colors from '../config/colors';
function AppButton({title, onPress, color = "primary", borderColor}) {
return (
<TouchableOpacity style={[
styles.button,
{backgroundColor: colors[color], borderColor: colors[borderColor] }]}
onPress={onPress}
>
<Text style={[styles.text]}>{title}</Text>
</TouchableOpacity>
);
}
const styles = StyleSheet.create({
button:{
backgroundColor: colors.primary,
borderRadius:15,
padding: 15,
width: "100%",
marginVertical: 10,
justifiedContent: 'center',
alignItems: 'center',
borderWidth: 6,
},
text:{
color: colors.white,
fontSize: 18,
textTransform: 'uppercase',
fontWeight: 'bold',
}
})
export default AppButton;
uj5u.com熱心網友回復:
從您的評論來看,似乎對這如何作業存在誤解。我
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/486054.html
標籤:javascript 反应 反应式
下一篇:在React中添加3D模型
