File tree 3 files changed +30
-6
lines changed
3 files changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,10 @@ function App() {
19
19
< h1 > 欢迎使用 webpack-react-typescript 模板</ h1 >
20
20
< Space size = { 60 } >
21
21
< Link to = "/" >
22
- < Button > HomePage</ Button >
22
+ < Button type = "primary" > HomePage</ Button >
23
23
</ Link >
24
24
< Link to = "/about" >
25
- < Button type = "primary" > AboutPage</ Button >
25
+ < Button > AboutPage</ Button >
26
26
</ Link >
27
27
</ Space >
28
28
Original file line number Diff line number Diff line change 1
- import React from 'react' ;
1
+ import React , { useState } from 'react' ;
2
+ import { Card , Tag } from 'antd' ;
2
3
3
4
const AboutPage = ( ) => {
4
- return < div > AboutPage</ div > ;
5
+ const [ count , setCount ] = useState ( 0 ) ;
6
+
7
+ return (
8
+ < Card title = "AboutPage" >
9
+ < Tag color = "error" onClick = { ( ) => setCount ( count + 1 ) } >
10
+ click here:{ count }
11
+ </ Tag >
12
+ </ Card >
13
+ ) ;
5
14
} ;
6
15
export default AboutPage ;
Original file line number Diff line number Diff line change 1
- import React from 'react' ;
1
+ import React , { useEffect , useState } from 'react' ;
2
+ import { Card , Tag } from 'antd' ;
2
3
3
4
const HomePage = ( ) => {
4
- return < div > HomePage</ div > ;
5
+ const [ count , setCount ] = useState ( 0 ) ;
6
+
7
+ useEffect ( ( ) => {
8
+ const Timer = setInterval ( ( ) => {
9
+ setCount ( prev => prev + 1 ) ;
10
+ } , 1000 ) ;
11
+
12
+ return ( ) => clearInterval ( Timer ) ;
13
+ } , [ ] ) ;
14
+
15
+ return (
16
+ < Card title = "HomePage" >
17
+ mounted start < Tag color = "cyan" > count:{ count } </ Tag > unmounted clear
18
+ </ Card >
19
+ ) ;
5
20
} ;
6
21
export default HomePage ;
You can’t perform that action at this time.
0 commit comments