@@ -6,7 +6,8 @@ import { connect } from "react-redux";
6
6
import { Route , Switch , Link } from "react-router-dom" ;
7
7
8
8
/** 所需的所有资源 **/
9
- import { Modal , Form , Button , message , Input , Icon } from "antd" ;
9
+ import { Modal , Form , Button , message , Input } from "antd" ;
10
+ import { UserOutlined , KeyOutlined } from "@ant-design/icons" ;
10
11
import "./index.less" ;
11
12
12
13
import ImgTest from "../../assets/test.jpg" ;
@@ -21,12 +22,16 @@ function TestPageContainer({
21
22
location, // 自动注入的location对象
22
23
match, // 自动注入的match对象
23
24
history, // 自动注入的history对象
24
- actions // 上面model中定义的actions对象,自动成为this.props.actions变量
25
+ actions, // 上面model中定义的actions对象,自动成为this.props.actions变量
25
26
} ) {
26
27
const [ visible , setVisible ] = useState ( false ) ; // 模态框隐藏和显示
27
28
const [ mokeFetch , setMokeFetch ] = useState ( [ ] ) ; // 用于测试fetch请求
28
29
// const [mokeAjax, setMokeAjax] = useState([]); // 用于测试ajax请求
29
30
const [ localCount , setLocalCount ] = useState ( 0 ) ; // 数字
31
+ const layout = {
32
+ labelCol : { span : 8 } ,
33
+ wrapperCol : { span : 16 } ,
34
+ } ;
30
35
31
36
// 仅组件加载完毕时触发一次
32
37
useEffect ( ( ) => {
@@ -85,17 +90,11 @@ function TestPageContainer({
85
90
< span className = "backImage" />
86
91
< span > 上方图片,一张是img,一张是background</ span >
87
92
< br />
88
- < span >
89
- 请特别注意,现在webpack.production.config.js中的publicPath配置为"/",
90
- </ span >
93
+ < span > 请特别注意,现在webpack.production.config.js中的publicPath配置为"/",</ span >
91
94
< br />
92
- < span >
93
- 如果你的项目最终打包后放到服务器上的访问路径为https://xxx.com,这没有问题
94
- </ span >
95
+ < span > 如果你的项目最终打包后放到服务器上的访问路径为https://xxx.com,这没有问题</ span >
95
96
< br />
96
- < span >
97
- 如果你的项目访问路径为https://xxx.com/aaa,请把webpack.production.config.js中的publicPath配置为"/aaa/"
98
- </ span >
97
+ < span > 如果你的项目访问路径为https://xxx.com/aaa,请把webpack.production.config.js中的publicPath配置为"/aaa/"</ span >
99
98
</ p >
100
99
</ div >
101
100
< div className = "list" >
@@ -128,24 +127,12 @@ function TestPageContainer({
128
127
< div className = "list" >
129
128
< h2 > Antd表单</ h2 >
130
129
< div style = { { maxWidth : "400px" } } >
131
- < Form onFinish = { handleSubmit } >
132
- < Form . Item
133
- label = "用户名"
134
- name = "username"
135
- rules = { [ { required : true , message : "请输入用户名" } ] }
136
- >
137
- < Input prefix = { < Icon type = "user" /> } placeholder = "用户名" />
130
+ < Form { ...layout } onFinish = { handleSubmit } >
131
+ < Form . Item label = "用户名" name = "username" rules = { [ { required : true , message : "请输入用户名" } ] } >
132
+ < Input prefix = { < UserOutlined /> } placeholder = "用户名" />
138
133
</ Form . Item >
139
- < Form . Item
140
- label = "密码"
141
- name = "password"
142
- rules = { [ { required : true , message : "请输入密码" } ] }
143
- >
144
- < Input
145
- type = "password"
146
- prefix = { < Icon type = "lock" /> }
147
- placeholder = "密码"
148
- />
134
+ < Form . Item label = "密码" name = "password" rules = { [ { required : true , message : "请输入密码" } ] } >
135
+ < Input type = "password" prefix = { < KeyOutlined /> } placeholder = "密码" />
149
136
</ Form . Item >
150
137
< Form . Item >
151
138
< Button type = "primary" htmlType = "submit" >
@@ -214,12 +201,7 @@ function TestPageContainer({
214
201
</ div >
215
202
</ div >
216
203
</ div >
217
- < Modal
218
- title = "模态框"
219
- visible = { visible }
220
- onOk = { ( ) => setVisible ( false ) }
221
- onCancel = { ( ) => setVisible ( false ) }
222
- >
204
+ < Modal title = "模态框" visible = { visible } onOk = { ( ) => setVisible ( false ) } onCancel = { ( ) => setVisible ( false ) } >
223
205
< p > 内容...</ p >
224
206
</ Modal >
225
207
</ div >
@@ -229,13 +211,13 @@ function TestPageContainer({
229
211
export default connect (
230
212
state => ( {
231
213
userinfo : state . app . userinfo , // 引入app model中的userinfo数据
232
- count : state . test . count // 引入test model中的count数据
214
+ count : state . test . count , // 引入test model中的count数据
233
215
} ) ,
234
216
dispatch => ( {
235
217
actions : {
236
218
getUserinfo : dispatch . app . getUserinfo , // 引入app model中的获取用户信息action
237
219
onTestAdd : dispatch . test . onTestAdd , // 引入test model中的数字+1 action
238
- serverFetch : dispatch . test . serverFetch // 引入test model中的fetch异步请求action
239
- }
240
- } )
220
+ serverFetch : dispatch . test . serverFetch , // 引入test model中的fetch异步请求action
221
+ } ,
222
+ } ) ,
241
223
) ( TestPageContainer ) ;
0 commit comments