content.jsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import React, { Component } from 'react';
  2. import '../content.less';
  3. import LeftTab from './leftTab';
  4. class Content extends Component {
  5. constructor() {
  6. super();
  7. this.state = {
  8. loading: false,
  9. component: 'div',
  10. };
  11. }
  12. componentWillMount() {
  13. if (window.location.hash) {
  14. this.getKey(window.location.hash.substr(1));
  15. } else {
  16. this.getKey("star");
  17. };
  18. }
  19. getKey(key) {
  20. switch (key) {
  21. case 'star':
  22. require.ensure([], () => {
  23. const Star = require('./bigShot/star').default;
  24. });
  25. break;
  26. };
  27. window.location.hash = key;
  28. }
  29. render() {
  30. return (
  31. <div className="manage-content">
  32. <LeftTab handlekey={this.getKey.bind(this)} />
  33. <div className="content-right">
  34. <this.state.component />
  35. </div>
  36. </div>
  37. )
  38. }
  39. }
  40. export default Content;