2016-11-04 54 views
1
export default class Help extends Component { 
    componentWillMount(){ 
     this.state = {open:false}; 
    } 


    handleOpen() { 
     this.setState({open: true}); 
    } 

    handleClose() { 
     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 className="container-fluid"> 
       <button type="button" className="btn btn-primary active" id="Hlp" onTouchTap={this.handleOpen}>Help</button> 
       <Dialog 
        title="Dialog With Actions" 
        actions={actions} 
        modal={false} 
        open={this.state.open} 
        onRequestClose={this.handleClose} 
        > 
        The actions in this window were passed in as an array of React objects. 
       </Dialog> 
      </div> 
     ); 
    } 
} 

我已經使用材料的UI的按鈕,點擊打開一個對話框,現在我看到控制檯中的一個錯誤,說無法讀取屬性「prepareStyles」的undefined..I可以看到按鈕在屏幕上如何開啓按鈕材料UI中的對話框中,單擊

回答

0

不知道,如果你從你只省略片斷他們,但要確保在你有合適的材料UI進口在頂部您的實際代碼:

import Dialog from 'material-ui/Dialog'; 
import FlatButton from 'material-ui/FlatButton'; 
+0

我沒有包括importa,但它肯定那些進口是出品者 – LOKI

+0

好的。在你最上面的組件(或其他父組件)中,你是否按照說明打包了MuiThemeProvider? http://www.material-ui.com/#/get-started/usage –

+1

添加muitheremprovider後,現在它工作正常.....感謝 – LOKI

相關問題