小编var*_*ika的帖子

循环显示多个菜单

我是 Material-ui 和 React 的新手,我需要在循环中动态创建多个菜单。请找到代码片段:

state = {
    anchorEl: null,
  };

  handleClick = event => {
    this.setState({ anchorEl: event.currentTarget });
  };

  handleClose = () => {
    this.setState({ anchorEl: null });
  };

    render() {
        const { anchorEl } = this.state;
        let items = _.map(results, (item, index) => {
        return (
              <ListItem
               key={item.ID}
               divider
              > 
              <ListItemSecondaryAction>
               <IconButton
                   aria-label="More"
                   aria-owns={anchorEl ? 'long-menu' : null}
                   aria-haspopup="true"
                   onClick={this.handleClick}
                  >
                  <MoreVertIcon />
                  </IconButton>
                  <Menu
                   id="long-menu"
                   anchorEl={anchorEl}
                   open={Boolean(anchorEl)}
                   onClose={this.handleClose}
                   PaperProps={{
                     style: {
                        maxHeight: 200,
                        width: 200,
                      }, …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui

0
推荐指数
1
解决办法
5827
查看次数

标签 统计

material-ui ×1

reactjs ×1