index.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import * as React from "react";
  2. import * as ReactDOM from "react-dom";
  3. import { LayoutDemo } from './NormalLayout/index';
  4. import { SortedTableWithStatic } from "./StaticWidget/index";
  5. import { LayoutRestore } from "./LayoutRestore/index";
  6. import { HandleLayout } from "./HandleLayout/index";
  7. // import { AddRemove } from "./AddRemove/index";
  8. import { Mobile } from "./mobileLayout/index";
  9. import './index.css'
  10. const DemoMap: any = {
  11. normalLayout: <LayoutDemo />,
  12. // SortedTable: <SortedTable />,
  13. StaticHeader: <SortedTableWithStatic />,
  14. LayoutRestore: <LayoutRestore />,
  15. HandleLayout: <HandleLayout />,
  16. // AddRemove: <AddRemove />,
  17. Mobile: <Mobile />
  18. }
  19. class DemoDispatcher extends React.Component<{}, {}> {
  20. state = {
  21. demo: <LayoutDemo />
  22. }
  23. handleLayoutChange = (demoName: string) => {
  24. this.setState({
  25. demo: DemoMap[demoName]
  26. })
  27. }
  28. render() {
  29. return (
  30. <div>
  31. <div>切换 Demos</div>
  32. <div className='demo-button-layout'>
  33. <button onClick={() => this.handleLayoutChange('normalLayout')}>普通布局</button>
  34. <button onClick={() => this.handleLayoutChange('StaticHeader')}>静态组件</button>
  35. <button onClick={() => this.handleLayoutChange('LayoutRestore')}>存储布局</button>
  36. <button onClick={() => this.handleLayoutChange('HandleLayout')}>拖拽把手</button>
  37. <button onClick={() => this.handleLayoutChange('Mobile')}>移动端</button>
  38. </div>
  39. {this.state.demo}
  40. </div>
  41. )
  42. }
  43. }
  44. <DemoDispatcher />
  45. ReactDOM.render(
  46. <DemoDispatcher />,
  47. document.getElementById('root')
  48. );
  49. document.addEventListener('touchmove', function (e) { e.preventDefault() }, false);