content.jsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. getKey(key) {
  20. switch (key) {
  21. case 'techDemand':
  22. require.ensure([], () => {
  23. const TechDemand = require('./techDemand').default;
  24. this.setState({
  25. component: TechDemand
  26. });
  27. });
  28. break;
  29. };
  30. window.location.hash = key;
  31. }
  32. render() {
  33. return (
  34. <div className="acc-content">
  35. <LeftTab handlekey={this.getKey.bind(this)} />
  36. <div className="content-right">
  37. <this.state.component />
  38. </div>
  39. </div>
  40. )
  41. }
  42. }
  43. export default Content;