Javascript 仅在某些屏幕上显示大写的本机基本文本
我在两个不同的组件中使用本机基本文本。在本例中,默认情况下,文本以大写形式显示,除非我添加Javascript 仅在某些屏幕上显示大写的本机基本文本,javascript,css,typescript,react-native,native-base,Javascript,Css,Typescript,React Native,Native Base,我在两个不同的组件中使用本机基本文本。在本例中,默认情况下,文本以大写形式显示,除非我添加uppercase={false} export const ActionButton: React.FunctionComponent<ActionButtonProps> = ({ style, disabled, buttonText, onPress, }) => { return ( <Button rounded onPress={onPres
uppercase={false}
export const ActionButton: React.FunctionComponent<ActionButtonProps> = ({
style,
disabled,
buttonText,
onPress,
}) => {
return (
<Button rounded onPress={onPress} disabled={disabled} style={[styles.button, style]}>
<Text uppercase={false} style={styles.text}>{buttonText}</Text>
</Button>
);
};
const styles = StyleSheet.create({
button: {
width: moderateScale(160),
height: moderateScale(50),
backgroundColor: '#31C283',
justifyContent: 'center',
},
text: { color: 'white', fontSize: moderateScale(13, 0.7), fontWeight:'600' },
});
导出常量操作按钮:React.FunctionComponent文本没有问题, 实际上,本机的基本按钮使它的孩子的文本大写。 这是源代码
我的问题是,为什么有些屏幕上的文本是大写的,而另一些屏幕上的文本是小写的。因为您已经将文本放在按钮中(在ActionButton文件中)。但你没有在TripOptionsSelector文件中这么做?为什么按钮会有所不同?如果不希望按钮大写,则应将buttonUppercaseAndroidText=false传递给button
export const TripOptionsSelector: React.FunctionComponent = () => {
const navigation = useNavigation();
return (
<View style={styles.offerContainer}>
<Text style={styles.offerText}>Jetzt</Text>
<Text style={styles.offerText}>1 Person</Text>
<Text style={styles.offerText} onPress={()=>navigation.navigate('TripFilter')}>Filter</Text>
</View>
);
};
const styles = StyleSheet.create({
offerContainer: {
flexDirection: 'row',
},
offerText: {
color: 'white',
marginRight: moderateScale(20),
paddingHorizontal: 10,
fontSize: moderateScale(14),
borderColor: 'white',
borderWidth: 1,
borderRadius: 10,
alignItems: 'center',
justifyContent: 'center',
},
});
const children =
Platform.OS === PLATFORM.IOS
? this.props.children
: React.Children.map(this.props.children, child =>
child && child.type === Text
? React.cloneElement(child, {
uppercase: this.props.buttonUppercaseAndroidText === false
? false : variables.buttonUppercaseAndroidText,
...child.props
})
: child
);