我想给 material-ui popover 提供图像中显示的以下形状。
我使用 react 创建了 popover 工作演示并共享链接以进行编辑。有什么帮助吗?=>工作演示
我也在此处共享代码,但如果将 stackblitz 工作演示用于编辑目的,那就太好了:
import React, { Component } from 'react';
import Popover, {PopoverAnimationVertical} from 'material-ui/Popover';
import Menu from 'material-ui/Menu';
import MenuItem from 'material-ui/MenuItem';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import { render } from 'react-dom';
import Hello from './Hello';
import './style.css';
const PopoverStyle = {
top: '50px'
};
class App extends Component {
constructor(props) {
super(props);
this.state = { pop_open: false };
}
handleProfileDropDown(e) {
e.preventDefault();
this.setState({
pop_open: !this.state.pop_open,
anchorEl: e.currentTarget,
});
}
handleRequestClose() {
this.setState({
pop_open: false,
});
};
render() {
return (
<div>
<MuiThemeProvider>
<button type="submit" name={this.state.name} onClick={this.handleProfileDropDown.bind(this)} >My Customized PopOver</button>
<Popover
open={this.state.pop_open}
anchorEl={this.state.anchorEl}
className="popover_class"
style={PopoverStyle}
anchorOrigin={{horizontal: 'left', vertical: 'bottom'}}
targetOrigin={{horizontal: 'left', vertical: 'top'}}
onRequestClose={this.handleRequestClose.bind(this)}
animation={PopoverAnimationVertical}
>
<Menu>
<MenuItem primaryText="Content" />
<MenuItem primaryText="My Profile" />
<MenuItem primaryText="Settings" />
<MenuItem primaryText="Logout" />
</Menu>
</Popover>
</MuiThemeProvider>
</div>
);
}
}
render(<App />, document.getElementById('root'));