【发布时间】:2017-04-22 17:35:30
【问题描述】:
我是 React Material UI 的新手,我正在尝试部署 AppBar,但我不知道如何将子项包含到此 NavBar 中。当我单击左三行菜单时,我想部署 AppBar。我的 .jsx 是:
import React from 'react';
import AppBar from 'material-ui/AppBar';
import IconButton from 'material-ui/IconButton';
import NavigationClose from 'material-ui/svg-icons/navigation/close';
import FlatButton from 'material-ui/FlatButton';
const STYLES = {
title: {
cursor: 'pointer',
},
titleStyle: {
textAlign: 'center'
},
buttonStyle: {
backgroundColor: 'transparent',
color: 'white'
}
};
const rightButtons = (
<div>
<FlatButton label="About" style={STYLES.buttonStyle} />
<FlatButton label="Home" style={STYLES.buttonStyle} />
</div>
);
export default class MenuAlumno extends React.Component {
constructor() {
super();
this.state = {
abierto:false
}
}
handleTouchTap = () => {
//alert('Has clickado sobre el título');
/*
console.log(this.state.abierto)
this.setState({
abierto:true
});
*/
console.log(this.state.abierto)
this.state.abierto = true;
console.log(this.state.abierto)
}
render() {
return (
<AppBar
title={<span style={STYLES.title}>- PLATAFORMA DE INCIDENCIAS -
</span>}
onTitleTouchTap={this.handleTouchTap}
titleStyle={STYLES.titleStyle}
iconClassNameRight="muidocs-icon-navigation-expand-more"
iconElementLeft={rightButtons}
>
</AppBar>
);
}
}
但此代码替换了 FlatButtons 的左 3 行。 当我单击 MenuButtonLeft 时,我希望使用包含我的网站(主页、关于我们、联系方式等)的页面部署一个侧边菜单。使用我之前放置的代码仅在工具栏中显示 MenuButtonLeft 和标题,但它不执行任何操作,它不会将任何带有 href 的菜单部署到我网站中的其他页面。
谢谢。
【问题讨论】:
-
你能详细说明一下,你想在这里实现什么
-
我想创建一个带有儿童的导航栏,而不仅仅是侧边栏
-
天哪,这个问题已经进入了正确的泡菜!标题给了它:这是两个问题,一个是
[solved],另一个是[edit]!不幸的是,这几乎不可读,而不是我们在这里使用的格式。如果您有一个新问题(或多个新问题,根据这种情况),请添加一个新问题。我已经把它回滚到第一个主要问题的最后一个已知的好版本。 -
下面的两个答案是什么?他们是针对第一个主要问题还是第二个主要问题?我想知道您现在是否最好再次向前滚动编辑(到第二个问题)并从根本上删除第一个问题,同时留下足够的上下文以使整个事情至少对新读者有所帮助。跨度>
-
不用说,请不要再这样做了 - 它会给志愿者带来编辑工作,我们已经有很多工作要做。
标签: reactjs ecmascript-6 material-ui