material ui DropDownMenu 用不了. 用的webpack
就是一打开网页下拉列表就打开了,怎么点都弄不消失。
控制台输出了几个 Warning: getInitialState was defined on xxxx(Paper, Menu, MenuItem之类的), a plain JavaScript class. This is only supported for classes created using React.createClass. Did you mean to define a state property instead?
每次点输入框都会抛出一个:Uncaught TypeError: Cannot read property 'style' of null
app.js
'use strict';
import ReactDOM from 'react-dom';
import React from 'react';
import injectTapEventPlugin from 'react-tap-event-plugin';
import DropDownMenu from 'material-ui/lib/drop-down-menu'
// Needed for onTouchTap
injectTapEventPlugin();
let menuItems = [
{ payload: '1', text: 'Never' },
{ payload: '2', text: 'Every Night' },
{ payload: '3', text: 'Weeknights' },
{ payload: '4', text: 'Weekends' },
{ payload: '5', text: 'Weekly' }
];
ReactDOM.render(<DropDownMenu valueMember="payload" style={{width: "100%"}} menuItems={menuItems} />, document.getElementById('app'));
webpack.config.js
var webpack = require('webpack'),
path = require('path'),
node_modules = path.resolve(__dirname, 'node_modules'),
pathToReact = path.resolve(node_modules, 'react/dist/react.min.js');
module.exports = {
entry: ['webpack/hot/dev-server', path.resolve(__dirname, 'app/app.js')],
output: {
path: path.resolve(__dirname, 'build'),
filename: 'app.bundle.js'
},
resolve: {
extensions: ['', '.js', '.jsx'],
alias: {
'react/lib': path.resolve(node_modules, 'react/lib'),
'react': pathToReact
}
},
module: {
loaders: [{
test: /\.js|jsx$/,
loaders: ['react-hot', 'babel'],
exclude: /node_modules/
}, {
test: /\.css$/,
loader: 'style!css'
}],
noParse: [pathToReact]
},
plugins: [new webpack.HotModuleReplacementPlugin()]
};
.babelrc
{
"presets": ["es2015", "react"]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MUI不能直接render的,你需要给父级组件设置muiTheme给child context.
详见:http://www.material-ui.com/#/customization/themes