所以我是 React 的新手(和 JavaScript 也是如此)。我正在使用 react native 创建一个应用程序,目前正在尝试设置我的弹出菜单的样式。(看起来像这样:弹出菜单图像)
我想更改选项的样式(使字体大小更大并将它们分开并更改字体颜色)。我的代码看起来像这样:
<MenuProvider>
<Menu >
<MenuTrigger>
<Image
style={styles.menucontainer}
resizeMode="contain"
source={require('../assets/icon_more.png')}>
</Image>
</MenuTrigger>
<MenuOptions optionsContainerStyle={styles.optionsstyle}>
<MenuOption text= 'About' />
<MenuOption text= 'Help & Feedback'/>
<MenuOption text= 'Sign Out'/>
</MenuOptions>
</Menu>
</MenuProvider>
检查
https://github.com/instea/react-native-popup-menu/blob/master/src/MenuOption.js后
,我找到了一个 prop customStyles
。就像我为MenuOptions
as prop传递了一个样式对象一样optionContainerStyle
,我尝试customStyles
为 MenuOption 传递一个样式对象,但这产生了一个错误:
在这种环境中,assign 的来源必须是一个对象。此错误是性能优化,不符合规范。
这是我的样式代码:
const styles = StyleSheet.create({
optionsstyle:{
marginTop: height*32/dev_dimension.h,
marginLeft: width*184/dev_dimension.w,
backgroundColor: '#fafafa',
width: width*168/dev_dimension.w,
height: height*160/dev_dimension.h,
flexDirection: 'row',
flex: 1,
justifyContent: 'space-between',
},
});
谁能告诉我做错了什么?