DropDown菜单未被查看

时间:2017-07-03 19:49:08

标签: javascript reactjs

我有一个映射的下拉菜单。我试图看看它是否有效,但是当我点击它时它就没有响应。它包含在一个按钮中。

代码段 -

const actions = ['Prof', 'Acct', 'LO'];

class NavigationBar extends Component {

constructor(props) {
  super(props);

  this.handleActionChange = this.handleActionChange.bind(this);
  this.state = {
    //actions() {},
   selectedAction: 1
 };

 this.classes = props.classes;
 this.currentTarget = null;
 this.notifs = this.notifs;
}

handleActionChange(event, selectedIndex, menuItems) {
 event.preventDefault();
 console.log(`You have selected ${actions[menuItems]} action`);
 this.setState({
  selectedAction: event.target.value
 });
}

handleClick = (event) => {
 this.currentTarget = event.currentTarget;
 console.log(event);
}

handleRequestClose() {
 this.close(false);
}


render() {

return (
  <AppBar className={this.classes.appBar}>
    <Toolbar>
     <div>
        <Button aria-owns="simple-menu" aria-haspopup="true" onClick=
         {this.handleActionChange}>
            <Avatar
              alt=""
              src="/avatars/.jpg" />
            <Menu value={this.state.selectedAction} onChange=
             {this.handleActionChange}
              openImmediately={true} onRequestClose=
              {this.handleRequestClose}>
                {actions.map((action, index) =>
                    <MenuItem key={actions} value=
              {this.state.selectedAction} primaryText{...action} />
                )}
              </Menu>
            </Button>
      </div>
     </Toolbar>
   </AppBar>

我无法弄清楚如何让它发挥作用。我也添加了注入点击事件。我使用的是react 15.0.1和material-ui alpha版本16和ES6。

0 个答案:

没有答案
相关问题