小编Zan*_*hin的帖子

使用 Material-UI 的数组中的多个悬停弹出框仅打开一个弹出框

我试图在一个页面上使用多个弹出窗口,但唯一要打开的弹出窗口是数组中的最后一个,无论您悬停在哪个触发元素上。这是使用 Material-UI v1.0.0-beta.46。

class MultiplePopover extends React.Component {
  constructor(props, context) {
    super(props, context);
    this.state = {
      open: false,
      anchorEl: null,
    };
    this.handlePopoverOpen = this.handlePopoverOpen.bind(this);
    this.handlePopoverClose = this.handlePopoverClose.bind(this);
  }
  handlePopoverOpen(event) {
    this.setState({
      anchorEl: event.target,
    });
  }
  handlePopoverClose() {
    this.setState({
      anchorEl: null,
    });
  }

  render() {
    const { classes } = this.props;
    const { anchorEl } = this.state;
    const open = !!anchorEl;


    const multi = [
      {
        _id: 0,
        name: 'name1',
        hoverText: 'text1',
        linkUrl: '#',
      },
      {
        _id: 1,
        name: 'name2',
        hoverText: …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui react-redux

3
推荐指数
1
解决办法
6222
查看次数

标签 统计

material-ui ×1

react-redux ×1

reactjs ×1