content.jsx 1.2 KB

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