我正在使用0.16.4材料-ui并试图使Drawer组件正常工作,但我无法轻扫工作。我自己无法弄清楚问题并成为新手我不知道我能做些什么。
import React from 'react';
import './App.css';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import Drawer from 'material-ui/Drawer';
import Chip from 'material-ui/Chip';
import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();
class App extends React.Component {
constructor() {
super();
this.state = {
open: true
}
}
render() {
return (
<MuiThemeProvider>
<Drawer
open={this.state.open}
docked={false}
onRequestChange={(o, r) => {
console.log(o + " reason:" + r);
this.setState({open: o});
}}
>
<Chip>"one"</Chip>
<Chip>"two"</Chip>
<Chip>"three"</Chip>
</Drawer>
</MuiThemeProvider>
);
}
}
export default App;
反应:15.4.0, material-ui:0.16.4, react-tap-event-plugin:2.0.1
答案 0 :(得分:2)
发现了这个问题。在我的情况下,身体长度为零,这就是无法识别滑动动作事件的原因。为了解决方法,我已经让身体占据了完整的视口,现在抽屉工作正常。
答案 1 :(得分:0)
添加
react-tap-event-plugin package
和:
import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();