Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 下拉菜单不是';没有人看见_Javascript_Reactjs - Fatal编程技术网

Javascript 下拉菜单不是';没有人看见

Javascript 下拉菜单不是';没有人看见,javascript,reactjs,Javascript,Reactjs,我有一个映射的下拉菜单。我试着看看它是否有效,但当我点击它时,它就是没有反应。它装在一个按钮里 代码片段- const actions = ['Prof', 'Acct', 'LO']; class NavigationBar extends Component { constructor(props) { super(props); this.handleActionChange = this.handleActionChange.bind(this); this.state

我有一个映射的下拉菜单。我试着看看它是否有效,但当我点击它时,它就是没有反应。它装在一个按钮里

代码片段-

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>
const actions=['Prof','Acct','LO'];
类导航栏扩展组件{
建造师(道具){
超级(道具);
this.handleActionChange=this.handleActionChange.bind(this);
此.state={
//动作(){},
所选操作:1
};
this.classes=props.classes;
this.currentTarget=null;
this.notifs=this.notifs;
}
handleActionChange(事件、selectedIndex、菜单项){
event.preventDefault();
log(`You have selected${actions[menuItems]}action`);
这是我的国家({
selectedAction:event.target.value
});
}
handleClick=(事件)=>{
this.currentTarget=event.currentTarget;
console.log(事件);
}
HandlerRequestClose(){
这个。关闭(假);
}
render(){
返回(
{actions.map((action,index)=>
)}

我无法确定如何使其工作。我还添加了注入点击事件。我使用的是react 15.0.1和material ui alpha版本16和ES6。

您有任何错误吗?您的JSX不应该包装在组件中的渲染方法中吗?抱歉,是的。刚刚编辑了帖子。我在控制台上看到的错误是“you have sel”未定义的动作'