Skip to content

Commit cf6b0e4

Browse files
committed
提交
1 parent 9a02fe4 commit cf6b0e4

File tree

8 files changed

+72
-107
lines changed

8 files changed

+72
-107
lines changed

src/App.css

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/App.js

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,72 @@
1-
import logo from './logo.svg';
2-
import './App.css';
3-
1+
import { useState } from 'react'
2+
let count = 100
3+
const getName = () => {
4+
return 'jsName'
5+
}
6+
const objList = [
7+
{ id: 1001, name: 'Vue' },
8+
{ id: 1002, name: 'React' },
9+
{ id: 1003, name: 'Angular' }
10+
]
11+
const flag = true
12+
const loading = false
13+
const articleType = 1
14+
const getArticleTem = () => {
15+
switch (articleType) {
16+
case 1:
17+
return <div>无图模式</div>
18+
case 2:
19+
return <div>有图模式</div>
20+
default:
21+
return <div>三图模式</div>
22+
}
23+
}
24+
// const addCount = (e) => {
25+
// console.log(e);
26+
// }
27+
const Button = () => {
28+
const [count1, setCount] = useState(0)
29+
const handleClick = () => {
30+
setCount(count1 + 1)
31+
}
32+
return (<div>
33+
<button onClick={() => handleClick()}>添加{count1}</button>
34+
</div>)
35+
}
36+
const Button1 = () => {
37+
const [form, setForm] = useState({ name: 'jack' })
38+
const handleClick = () => {
39+
setForm({ ...form, name: 'jai' })
40+
}
41+
return (<div>
42+
<button onClick={() => handleClick()}>添加{form.name}</button>
43+
</div>)
44+
}
445
function App() {
546
return (
647
<div className="App">
7-
<header className="App-header">
8-
<img src={logo} className="App-logo" alt="logo" />
9-
<p>
10-
Edit <code>src/App.js</code> and save to reload.
11-
</p>
12-
<a
13-
className="App-link"
14-
href="https://reactjs.org"
15-
target="_blank"
16-
rel="noopener noreferrer"
17-
>
18-
Learn React
19-
</a>
20-
</header>
48+
111111
49+
{`jjjjj`}
50+
{count}
51+
{getName()}
52+
{new Date().getTime()}
53+
<div style={{ color: 'red' }}>this is a div</div>
54+
<div>
55+
<ul>
56+
{
57+
objList.map(item => <li key={item.id}>{item.name}</li>)
58+
}
59+
</ul>
60+
</div>
61+
<div>
62+
{flag && <div style={{ color: 'red' }}>this is a div</div>}
63+
{loading ? <div style={{ color: 'red' }}>loading...</div> : <div>this is span</div>}
64+
</div>
65+
<div>
66+
{getArticleTem()}
67+
</div>
68+
<Button />
69+
<Button1 />
2170
</div>
2271
);
2372
}

src/App.test.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/index.css

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/index.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1+
// 项目入口
2+
// 核心包
13
import React from 'react';
24
import ReactDOM from 'react-dom/client';
3-
import './index.css';
5+
// 导入项目根组件
46
import App from './App';
5-
import reportWebVitals from './reportWebVitals';
6-
7+
// 把App根组件 渲染到id为rootdedom节点上
78
const root = ReactDOM.createRoot(document.getElementById('root'));
8-
root.render(
9-
<React.StrictMode>
10-
<App />
11-
</React.StrictMode>
12-
);
9+
root.render(<App />);
10+
1311

14-
// If you want to start measuring performance in your app, pass a function
15-
// to log results (for example: reportWebVitals(console.log))
16-
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17-
reportWebVitals();

src/logo.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/reportWebVitals.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/setupTests.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)