已关闭。此问题需要更多focused。当前不接受答案。**想要改进此问题吗?**更新问题,使其仅关注editing this post的一个问题。
5天前关闭。Improve this question
我想在react原生应用中实现这种菜单
goqiplq21#
使用如下代码
import * as React from 'react'; import { View } from 'react-native'; import { Button, Menu, Divider, Provider } from 'react-native-paper'; const MyComponent = () => { const [visible, setVisible] = React.useState(false); const openMenu = () => setVisible(true); const closeMenu = () => setVisible(false); return ( <Provider> <View style={{ paddingTop: 50, flexDirection: 'row', justifyContent: 'center', }}> <Menu visible={visible} onDismiss={closeMenu} anchor={<Button onPress={openMenu}>Show menu</Button>}> <Menu.Item onPress={() => {}} title="Item 1" /> <Menu.Item onPress={() => {}} title="Item 2" /> <Divider /> <Menu.Item onPress={() => {}} title="Item 3" /> </Menu> </View> </Provider> ); }; export default MyComponent;
必须读取this和this
1条答案
按热度按时间goqiplq21#
使用如下代码
必须读取this和this