Skip to content

Commit cbf94e1

Browse files
committed
update antd 4.0
1 parent 14c5087 commit cbf94e1

File tree

1 file changed

+20
-38
lines changed

1 file changed

+20
-38
lines changed

src/container/test/index.js

+20-38
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { connect } from "react-redux";
66
import { Route, Switch, Link } from "react-router-dom";
77

88
/** 所需的所有资源 **/
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";
1011
import "./index.less";
1112

1213
import ImgTest from "../../assets/test.jpg";
@@ -21,12 +22,16 @@ function TestPageContainer({
2122
location, // 自动注入的location对象
2223
match, // 自动注入的match对象
2324
history, // 自动注入的history对象
24-
actions // 上面model中定义的actions对象,自动成为this.props.actions变量
25+
actions, // 上面model中定义的actions对象,自动成为this.props.actions变量
2526
}) {
2627
const [visible, setVisible] = useState(false); // 模态框隐藏和显示
2728
const [mokeFetch, setMokeFetch] = useState([]); // 用于测试fetch请求
2829
// const [mokeAjax, setMokeAjax] = useState([]); // 用于测试ajax请求
2930
const [localCount, setLocalCount] = useState(0); // 数字
31+
const layout = {
32+
labelCol: { span: 8 },
33+
wrapperCol: { span: 16 },
34+
};
3035

3136
// 仅组件加载完毕时触发一次
3237
useEffect(() => {
@@ -85,17 +90,11 @@ function TestPageContainer({
8590
<span className="backImage" />
8691
<span>上方图片,一张是img,一张是background</span>
8792
<br />
88-
<span>
89-
请特别注意,现在webpack.production.config.js中的publicPath配置为"/",
90-
</span>
93+
<span>请特别注意,现在webpack.production.config.js中的publicPath配置为"/",</span>
9194
<br />
92-
<span>
93-
如果你的项目最终打包后放到服务器上的访问路径为https://xxx.com,这没有问题
94-
</span>
95+
<span>如果你的项目最终打包后放到服务器上的访问路径为https://xxx.com,这没有问题</span>
9596
<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>
9998
</p>
10099
</div>
101100
<div className="list">
@@ -128,24 +127,12 @@ function TestPageContainer({
128127
<div className="list">
129128
<h2>Antd表单</h2>
130129
<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="用户名" />
138133
</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="密码" />
149136
</Form.Item>
150137
<Form.Item>
151138
<Button type="primary" htmlType="submit">
@@ -214,12 +201,7 @@ function TestPageContainer({
214201
</div>
215202
</div>
216203
</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)}>
223205
<p>内容...</p>
224206
</Modal>
225207
</div>
@@ -229,13 +211,13 @@ function TestPageContainer({
229211
export default connect(
230212
state => ({
231213
userinfo: state.app.userinfo, // 引入app model中的userinfo数据
232-
count: state.test.count // 引入test model中的count数据
214+
count: state.test.count, // 引入test model中的count数据
233215
}),
234216
dispatch => ({
235217
actions: {
236218
getUserinfo: dispatch.app.getUserinfo, // 引入app model中的获取用户信息action
237219
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+
}),
241223
)(TestPageContainer);

0 commit comments

Comments
 (0)