如何在电子中使用材料-ui

时间:2016-09-26 23:50:37

标签: electron material-ui

我的代码alwasy电子控制台错误和网络浏览器中的相同代码没有错误;

import React, { Component } from 'react';
import { Router, Route, Link, browserHistory ,hashHistory} from 'react-router'
import { render } from 'react-dom';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import injectTapEventPlugin from 'react-tap-event-plugin';
import { RaisedButton } from 'material-ui';
class App extends Component {
  render() {
    return (
      <MuiThemeProvider>
        <RaisedButton className="submit" label='xxxxxxx' labelColor="#fff" backgroundColor="#32a62e"></RaisedButton>
      </MuiThemeProvider>
    )
  }
}

injectTapEventPlugin();

let rootElement = document.getElementById('containers');
render(
  <App/>,
  rootElement
)

enter image description here

1 个答案:

答案 0 :(得分:1)

您需要添加

import injectTapEventPlugin from 'react-tap-event-plugin';

injectTapEventPlugin();

到javascript文件的顶层,如文档的this页面中所述。这是因为onTouchTap对此模块有依赖性,所以在类定义之前或者在你拥有的顶级js文件中移动它。