|
1 |
| -import 'react-app-polyfill/ie11'; |
2 |
| -import * as React from 'react'; |
3 |
| -import * as ReactDOM from 'react-dom'; |
4 |
| -import JsonEditor from '../.'; |
5 |
| -// import './reset.css'; |
| 1 | +import 'react-app-polyfill/ie11' |
| 2 | +import 'react-json-syntax-highlighter/dist/ReactJsonSyntaxHighlighter.css' |
| 3 | + |
| 4 | +import * as React from 'react' |
| 5 | +import * as ReactDOM from 'react-dom' |
| 6 | +import ReactJsonSyntaxHighlighter from 'react-json-syntax-highlighter' |
| 7 | + |
| 8 | +import JsonEditor from '../' |
| 9 | + |
6 | 10 | const App = () => {
|
7 | 11 | const [editObject, setEditObject] = React.useState<any>({
|
8 |
| - field: 'assignee', |
9 |
| - list: [1, 2, 3], |
10 |
| - from: { |
11 |
| - name: 'zhangsan', |
12 |
| - type: 'crazy person', |
| 12 | + name: 'may', |
| 13 | + age: null, |
| 14 | + address: [ |
| 15 | + 'Panyu Shiqiao on Canton', |
| 16 | + 'Tianhe', |
| 17 | + { |
| 18 | + city: 'forida meta 11', |
| 19 | + }, |
| 20 | + ], |
| 21 | + ohters: { |
| 22 | + id: 1246, |
| 23 | + joinTime: '2017-08-20. 10:20', |
| 24 | + description: 'another', |
13 | 25 | },
|
14 |
| - tmpFromAccountId: null, |
15 |
| - }); |
| 26 | + }) |
16 | 27 |
|
17 | 28 | return (
|
18 |
| - <div style={{ padding: '10px' }}> |
| 29 | + <div> |
| 30 | + <h1 style={{ textAlign: 'center', padding: '50px 0' }}> |
| 31 | + React Json Edit |
| 32 | + </h1> |
19 | 33 | <div style={{ display: 'flex', justifyContent: 'center' }}>
|
20 | 34 | <div
|
21 | 35 | style={{
|
22 | 36 | width: '550px',
|
23 |
| - border: '1px solid black', |
24 | 37 | padding: '10px',
|
| 38 | + marginRight: '2px', |
| 39 | + backgroundColor: '#fcfcfc', |
| 40 | + borderRadius: '2px', |
25 | 41 | }}
|
26 | 42 | >
|
27 | 43 | <JsonEditor
|
28 | 44 | data={editObject}
|
29 | 45 | onChange={data => {
|
30 |
| - setEditObject(data); |
| 46 | + setEditObject(data) |
31 | 47 | }}
|
32 | 48 | />
|
33 | 49 | </div>
|
34 | 50 | <div
|
35 | 51 | style={{
|
36 |
| - width: '600px', |
37 |
| - border: '1px solid black', |
| 52 | + width: '550px', |
38 | 53 | padding: '10px',
|
| 54 | + marginLeft: '2px', |
| 55 | + backgroundColor: '#F5F5F5', |
| 56 | + borderRadius: '2px', |
39 | 57 | }}
|
40 | 58 | >
|
41 |
| - <pre>{JSON.stringify(editObject, null, 2)}</pre> |
| 59 | + <ReactJsonSyntaxHighlighter obj={editObject} /> |
42 | 60 | </div>
|
43 | 61 | </div>
|
44 | 62 | </div>
|
45 |
| - ); |
46 |
| -}; |
| 63 | + ) |
| 64 | +} |
47 | 65 |
|
48 |
| -ReactDOM.render(<App />, document.getElementById('root')); |
49 |
| -// const root = ReactDOM.createRoot( |
50 |
| -// document.getElementById('root') as HTMLElement |
51 |
| -// ); |
52 |
| -// root.render( |
53 |
| -// <React.StrictMode> |
54 |
| -// <App /> |
55 |
| -// </React.StrictMode> |
56 |
| -// ); |
| 66 | +ReactDOM.render(<App />, document.getElementById('root')) |
0 commit comments