├── .gitattributes
├── .gitignore
├── .idea
├── misc.xml
├── modules.xml
├── react-app.iml
├── vcs.xml
└── workspace.xml
├── README.md
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
└── manifest.json
└── src
├── index.css
├── index.js
└── index2.js
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 | # testing
7 | /coverage
8 |
9 | # production
10 | /build
11 |
12 | # misc
13 | .DS_Store
14 | .env.local
15 | .env.development.local
16 | .env.test.local
17 | .env.production.local
18 |
19 | npm-debug.log*
20 | yarn-debug.log*
21 | yarn-error.log*
22 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/react-app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
89 |
90 |
91 |
92 | element
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 | true
113 |
114 | false
115 | true
116 | true
117 |
118 |
119 | true
120 | DEFINITION_ORDER
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 | AngularJS
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 | 1517984462046
216 |
217 |
218 | 1517984462046
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Table of Contents
4 |
5 | this is a react app
6 |
7 | 这是一个react cli 创建的web app
8 |
9 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "reacte-app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "hoek": "^5.0.3",
7 | "react": "^16.2.0",
8 | "react-dom": "^16.2.0",
9 | "react-scripts": "1.1.0"
10 | },
11 | "scripts": {
12 | "start": "react-scripts start",
13 | "build": "react-scripts build",
14 | "test": "react-scripts test --env=jsdom",
15 | "eject": "react-scripts eject"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hzlshen/react-web/c8234b2fc5c5beca8d35b35e2d590e202fb9ceb1/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
22 | React App
23 |
24 |
25 |
28 |
29 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | }
10 | ],
11 | "start_url": "./index.html",
12 | "display": "standalone",
13 | "theme_color": "#000000",
14 | "background_color": "#ffffff"
15 | }
16 |
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | font: 14px "Century Gothic", Futura, sans-serif;
3 | margin: 20px;
4 | }
5 | ol,li{
6 | padding-left: 30px;
7 | }
8 | .board-row:after {
9 | clear: both;
10 | content: "";
11 | display: table;
12 | }
13 | .status {
14 | margin-bottom: 10px;
15 | }
16 |
17 | .square {
18 | background: #fff;
19 | border: 1px solid #999;
20 | float: left;
21 | font-size: 24px;
22 | font-weight: bold;
23 | line-height: 34px;
24 | height: 34px;
25 | margin-right: -1px;
26 | margin-top: -1px;
27 | padding: 0;
28 | text-align: center;
29 | width: 34px;
30 | }
31 |
32 | .square:focus {
33 | outline: none;
34 | }
35 |
36 | .kbd-navigation .square:focus {
37 | background: #ddd;
38 | }
39 |
40 | .game {
41 | display: flex;
42 | flex-direction: row;
43 | }
44 |
45 | .game-info {
46 | margin-left: 20px;
47 | }
48 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 |
5 | //JSX, 一种 JavaScript 的语法扩展
6 | function formatName(user) {
7 | return user.firstName + '' +user.lastName;
8 | }
9 |
10 | const user ={
11 | firstName : '神威如狱',
12 | lastName : '不动的推动者'
13 | };
14 |
15 | const element = (
16 |
17 | Hello, {formatName(user)}
18 |
19 | );
20 |
21 | //JSX本身其实也是一种表达式
22 | //可传参 可作返回值
23 | function getGreeting(user) {
24 | if(user){
25 | return Hello,{formatName(user)}!
;
26 | }
27 | return Hello , 啊哈哈哈
;
28 | }
29 | //也可以用引号来定义以字符串为值的属性
30 | const element1= ;
31 | //也可以用大括号
32 | const element2 =
;
33 | //相互嵌套
34 | const element3 =(
35 |
36 |
小龟龟
37 | 你好啊!世界!
38 |
39 | )
40 |
41 | //JSX防注入攻击
42 | // const title = response.potentiallyMaliciousInput;
43 | //直接使用是安全的
44 | // const element4 ={title}
45 |
46 | //JSX代表Objects React.createElement()方法调用
47 | //这两种代码作用是完全相同的
48 | const element6 = (
49 | Hello , world!
50 | );
51 |
52 | const element8 = React.createElement(
53 | 'h1',
54 | {
55 | className:'greeting'
56 | },
57 | 'Hello , world'
58 | )
59 | //React.createElement()首先会进行避免bug的检查
60 | const elay = {
61 | type:'h1',
62 | props:'greeting',
63 | children:'Hello world'
64 | }
65 |
66 | ReactDOM.render(
67 | element3,document.getElementById('root')
68 | )
--------------------------------------------------------------------------------
/src/index2.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 |
5 | //渲染页面
6 | //传入 ReactDOM.render() 方法
7 | function tick() {
8 | const element = (
9 |
10 |
你好,小伙子
11 | 这是一个帅气的小伙子
12 |
13 | );
14 | ReactDOM.render(
15 | element,
16 | document.getElementById('root')
17 | );
18 | }
19 |
20 | function Welcome(props) {
21 | return Hello ,{props.name}
22 | }
23 |
24 | class Welcome extends React.Component{
25 | render(){
26 | return 你好啊小伙子,{this.props.name}
27 | }
28 | }
29 |
30 | //前面渲染的都是dom标签
31 | //也可以自定义用户组件
32 | const element1 = ;
33 | //将JSX属性作为单个对象传递给该组件,这个对象称之为“props”。
34 | function Welcome(props){
35 | return Hello ,{props.name}
36 | }
37 |
38 | const element = ;
39 | ReactDOM.render(
40 | element,
41 | document.getElementById('root')
42 | );
43 |
44 | //注意:组件名称必须以大写字母开头。
45 |
46 | //组合组件
47 | function App(){
48 | return (
49 |
50 |
51 |
52 |
53 | )
54 | }
55 |
56 |
57 |
58 |
59 | ReactDOM.render(
60 | element,document.getElementById('root')
61 | )
--------------------------------------------------------------------------------