我試圖通過單擊按鈕打開Dialog
框。 當我點擊Dialog
首先是未打開按鈕,我得到錯誤:無法讀取undefined屬性'prepareStyles'
Uncaught TypeError: Cannot read property 'prepareStyles' of undefined.
這裏是我的組件的代碼:
const muiThemebtn = getMuiTheme({
palette: {
alternateTextColor: darkBlack,
primary1Color: grey100,
}
})
export default class MyComponent extends React.Component {
constructor (props) {
super(props);
this.state = {open: true};
this.openModal = this.openModal.bind(this);
this.closeModal = this.closeModal.bind(this);
}
openModal=()=>{ this.setState({open: true}); }
closeModal=()=>{ this.setState({open: false}); }
render() {
const actions = [
<FlatButton
label="Cancel"
primary={true}
onTouchTap={this.handleClose}
/>,
<FlatButton
label="Submit"
primary={true}
keyboardFocused={true}
onTouchTap={this.handleClose}
/>,
];
return (
<div>
<MuiThemeProvider muiTheme={muiThemebtn}>
<RaisedButton label={Lang.AddUser}
onTouchTap={this.openModal}
primary={true}
display='none'
icon={<ContentAddBox color={darkBlack} style={{backgroundColor:'#e3e3e3'}}/>}
/>
</MuiThemeProvider>
<Dialog
title="Scrollable Dialog"
actions={actions}
modal={false}
open={this.state.open}
onRequestClose={this.handleClose}
autoScrollBodyContent={true}
>
Dialog Text
</Dialog>
</div>
);
}
}
請建議。 注:我需要使用MuiThemeProvider
不錯的建議,對不起,我忘了提,我加你的建議我的回答,+1爲此,現在你有信譽評論任何帖子:) –
Woot!謝謝 :) –