index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React from 'react';
  2. import { Nav, Button } from '@douyinfe/semi-ui';
  3. import {IconStar, IconSetting,IconUser} from '@douyinfe/semi-icons';
  4. const items2 = [
  5. { itemKey: 'union', text: '公会中心', icon: <IconStar /> },
  6. { text: '任务平台', icon: <IconSetting />, itemKey: 'job', items: ['任务管理', '用户任务查询'] },
  7. ];
  8. class NavApp extends React.Component {
  9. constructor(props) {
  10. super(props);
  11. this.state = {
  12. items: [
  13. { itemKey: 'user', text: '用户管理', icon: <IconUser /> },
  14. { itemKey: 'union', text: '公会中心', icon: <IconStar /> },
  15. { itemKey: 'job', text: '任务平台', icon: <IconSetting />, items: ['任务管理', '用户任务查询'] },
  16. ],
  17. };
  18. this.change = this.change.bind(this);
  19. }
  20. change() {
  21. if (this.state.items.length === 3) {
  22. this.setState({ items: items2 });
  23. } else {
  24. this.setState({ items: [] });
  25. }
  26. }
  27. render() {
  28. return (
  29. <>
  30. <Button onClick={this.change}>change items</Button>
  31. <br />
  32. <br />
  33. <Nav bodyStyle={{ height: 150 }} items={this.state.items} />
  34. </>
  35. );
  36. }
  37. }
  38. export default NavApp;