2
我Component
看起來像ReactJS:材質UI浮動按鈕onTouchTap調用的URL列表項它
const style = {
margin: 0,
top: 'auto',
right: 20,
bottom: 20,
left: 'auto',
position: 'fixed',
};
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
open: false
}
}
toggleDrawer =() => this.setState({open: !this.state.open});
handleAddMenu =() => {
console.log("Opening New Menu Form");
this.props.history.push("/addMenu");
}
render() {
return (
<div>
<AppBar
title="SpicyVeggie"
iconClassNameRight="muidocs-icon-navigation-expand-more"
onLeftIconButtonTouchTap={this.toggleDrawer}
/>
<Drawer
docked={false}
width={300}
onRequestChange={this.toggleDrawer}
open={this.state.open}
>
<AppBar title="SpicyVeggie" onLeftIconButtonTouchTap={this.toggleDrawer} />
<MenuItem
primaryText="Menu"
containerElement={<Link to="/menu"/>}
onTouchTap={() => {
this.toggleDrawer()
}}
/>
<MenuItem
primaryText="Summary"
containerElement={<Link to="/summary"/>}
onTouchTap={() => {
this.toggleDrawer()
}}
/>
</Drawer>
<div className="container">
{this.props.children}
</div>
<div>
<FloatingActionButton
style={style}
mini={true}
secondary={true}
onTouchTap={this.handleAddMenu}>
<ContentAdd />
</FloatingActionButton>
</div>
</div>
);
}
}
export default App;
之下,所以當我點擊Add
,它觸發按鈕下面的ListItem
的onTouchTap
。
第二次,當它下面沒有ListItem
,並且我點擊「添加」時,它會爲添加調用正確的onTouchTap
事件。
我該如何解決它的第一種情況,優先onTouchTap
FloatingActionButton
?
什麼反應,和/材料-UI您使用的版本? –
'「material-ui」:「^ 0.17.4」'。這是我擁有的版本 – daydreamer