【发布时间】:2018-04-23 06:27:48
【问题描述】:
我的应用程序在使用 material-ui 的 react 可滑动标签时遇到了问题。我安装并完成了文档中推荐的所有操作。 现在,我在屏幕截图上显示以下错误。从材料 ui 中合并 可滑动标签 是否有任何问题。因为当我使用受控示例时,它运行良好,没有显示错误。
目前我正在使用以下代码:
import React, { Component } from 'react';
import {Tabs, Tab} from 'material-ui/Tabs';
import SwipeableViews from 'react-swipeable-views';
const styles = {
headline: {
fontSize: 24,
paddingTop: 16,
marginBottom: 12,
fontWeight: 400,
},
slide: {
padding: 10,
},
};
export default class ProfileTabSection extends Component {
constructor(props) {
super(props);
this.state = {
slideIndex: 0,
};
this.handleChange = this.handleChange.bind(this);
}
handleChange(value) {
this.setState({
slideIndex: value,
});
};
render() {
return(
<div>
<div className="container-fluid profile-tab-section">
<Tabs
onChange={this.handleTabChange}
value={this.state.slideIndex}
>
<Tab label="Feed" value={0} />
<Tab label="All posts" value={1} />
<Tab label="Followers" value={2} />
<Tab label="Following" value={3} />
</Tabs>
<SwipeableViews
index={this.state.slideIndex}
onChangeIndex={this.handleChange}
>
<div id="feed_slide">
It's a feed slide </div>
<div id="all_posts_slide" style={styles.slide}>
It's an all posts slide!
</div>
<div id="followers_slide" style={styles.slide}>
Followers
</div>
<div id="following_slide" style={styles.slide}>
Following
</div>
</SwipeableViews>
</div>
</div>
);
}
}
【问题讨论】:
-
rm -rf node_modules和npm install应该可以解决问题 -
应用了,但仍然遇到同样的问题
标签: javascript reactjs tabs material-ui react-component