React native textTransform在本机抽屉选项中无效?
我希望抽屉选项中的文本为大写。所以我做了下面的代码React native textTransform在本机抽屉选项中无效?,react-native,navigation-drawer,React Native,Navigation Drawer,我希望抽屉选项中的文本为大写。所以我做了下面的代码 const drawerOptions = { drawerPosition:'right', drawerBackgroundColor:'#86959a', contentOptions:{ activeTintColor:'white', inactiveTintColor:'white', labelStyle:{textTransform:'uppercase'}
const drawerOptions = {
drawerPosition:'right',
drawerBackgroundColor:'#86959a',
contentOptions:{
activeTintColor:'white',
inactiveTintColor:'white',
labelStyle:{textTransform:'uppercase'}
},
};
const Navigator = DrawerNavigator(Router,drawerOptions);
然而,我得到了一个警告
警告:失败的道具类型:无效的道具样式键textcransform
提供给Text
如何将抽屉菜单中的菜单项设置为大写?您可能正在使用传递所需的文本?因此,您可以手动将文本设置为大写,如下所示:
static navigationOptions = {
drawerLabel: 'MENU ITEM'
};
如果传入的是变量而不是手动输入的字符串,则可以使用JavaScript的toUpperCase()
函数:
const menuItem = 'menu item';
static navigationOptions = {
drawerLabel: menuItem.toUpperCase()
};
哦,所以在react native中没有文本转换大写这样的东西?实际上,没有-看看这里:react native不支持所有CSS属性,但我们可以使用JS来补偿。同时,React支持与常规web开发类似的常规CSS和样式表。