Skip to content

Commit 14c5087

Browse files
committed
update antd 4.0
1 parent 85e1139 commit 14c5087

File tree

3 files changed

+40
-54
lines changed

3 files changed

+40
-54
lines changed

package.json

+17-17
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,34 @@
2323
"pnp": false
2424
},
2525
"dependencies": {
26-
"@rematch/core": "^1.3.0",
27-
"antd": "3.26.7",
26+
"@rematch/core": "^1.4.0",
27+
"antd": "4.0.0",
2828
"axios": "^0.19.2",
2929
"core-js": "^3.6.4",
3030
"history": "^4.10.1",
3131
"lodash": "^4.17.15",
32-
"react": "^16.12.0",
33-
"react-dom": "^16.12.0",
32+
"react": "^16.13.0",
33+
"react-dom": "^16.13.0",
3434
"react-loadable": "^5.5.0",
35-
"react-redux": "^7.1.3",
35+
"react-redux": "^7.2.0",
3636
"react-router-dom": "^5.1.2",
3737
"redux": "^4.0.5"
3838
},
3939
"devDependencies": {
40-
"@babel/core": "^7.8.3",
40+
"@babel/core": "^7.8.6",
4141
"@babel/plugin-proposal-class-properties": "^7.8.3",
4242
"@babel/plugin-proposal-decorators": "^7.8.3",
4343
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
4444
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
4545
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
4646
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
4747
"@babel/plugin-transform-runtime": "^7.8.3",
48-
"@babel/preset-env": "^7.8.3",
48+
"@babel/preset-env": "^7.8.6",
4949
"@babel/preset-react": "^7.8.3",
50-
"@babel/runtime": "^7.8.3",
50+
"@babel/runtime": "^7.8.4",
5151
"antd-dayjs-webpack-plugin": "^0.0.8",
5252
"autoprefixer": "^9.7.4",
53-
"babel-eslint": "^10.0.3",
53+
"babel-eslint": "^10.1.0",
5454
"babel-loader": "^8.0.6",
5555
"babel-plugin-import": "^1.13.0",
5656
"body-parser": "^1.19.0",
@@ -59,14 +59,14 @@
5959
"eslint": "^6.8.0",
6060
"eslint-loader": "^3.0.3",
6161
"eslint-plugin-prettier": "^3.1.2",
62-
"eslint-plugin-react": "^7.18.0",
63-
"eslint-plugin-react-hooks": "^2.3.0",
62+
"eslint-plugin-react": "^7.18.3",
63+
"eslint-plugin-react-hooks": "^2.5.0",
6464
"express": "^4.17.1",
65-
"favicons-webpack-plugin": "3.0.0",
66-
"file-loader": "^5.0.2",
65+
"favicons-webpack-plugin": "3.0.1",
66+
"file-loader": "^5.1.0",
6767
"happypack": "^5.0.1",
6868
"html-webpack-plugin": "^4.0.0-beta.11",
69-
"less": "^3.10.3",
69+
"less": "^3.11.1",
7070
"less-loader": "^5.0.0",
7171
"mini-css-extract-plugin": "^0.9.0",
7272
"mockjs": "^1.1.0",
@@ -75,10 +75,10 @@
7575
"prettier": "1.19.1",
7676
"style-loader": "1.1.3",
7777
"sw-precache-webpack-plugin": "^1.0.0",
78-
"terser-webpack-plugin": "^2.3.3",
78+
"terser-webpack-plugin": "^2.3.5",
7979
"url-loader": "^3.0.0",
80-
"webpack": "^4.41.5",
81-
"webpack-cli": "^3.3.10",
80+
"webpack": "^4.42.0",
81+
"webpack-cli": "^3.3.11",
8282
"webpack-dev-middleware": "^3.7.2",
8383
"webpack-hot-middleware": "^2.25.0",
8484
"webpackbar": "^4.0.0",

src/container/test/index.js

+21-31
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ function TestPageContainer({
2121
location, // 自动注入的location对象
2222
match, // 自动注入的match对象
2323
history, // 自动注入的history对象
24-
actions, // 上面model中定义的actions对象,自动成为this.props.actions变量
25-
form // antd的form表单高阶组件自动注入的form对象
24+
actions // 上面model中定义的actions对象,自动成为this.props.actions变量
2625
}) {
2726
const [visible, setVisible] = useState(false); // 模态框隐藏和显示
2827
const [mokeFetch, setMokeFetch] = useState([]); // 用于测试fetch请求
@@ -70,18 +69,11 @@ function TestPageContainer({
7069
});
7170
}
7271

73-
// 表单提交登录
72+
// 表单提交且验证通过时触发
7473
function handleSubmit(e) {
75-
e.preventDefault();
76-
form.validateFields((err, values) => {
77-
if (!err) {
78-
message.success("执行了登录操作");
79-
}
80-
});
74+
message.success("执行了登录操作");
8175
}
8276

83-
const { getFieldDecorator } = form;
84-
8577
return (
8678
<div className="page-test">
8779
<h1 className="title">功能测试</h1>
@@ -136,24 +128,24 @@ function TestPageContainer({
136128
<div className="list">
137129
<h2>Antd表单</h2>
138130
<div style={{ maxWidth: "400px" }}>
139-
<Form onSubmit={handleSubmit}>
140-
<Form.Item>
141-
{getFieldDecorator("username", {
142-
rules: [{ required: true, message: "请输入用户名" }]
143-
})(
144-
<Input prefix={<Icon type="user" />} placeholder="用户名" />
145-
)}
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="用户名" />
146138
</Form.Item>
147-
<Form.Item>
148-
{getFieldDecorator("password", {
149-
rules: [{ required: true, message: "请输入密码" }]
150-
})(
151-
<Input
152-
type="password"
153-
prefix={<Icon type="lock" />}
154-
placeholder="密码"
155-
/>
156-
)}
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+
/>
157149
</Form.Item>
158150
<Form.Item>
159151
<Button type="primary" htmlType="submit">
@@ -234,8 +226,6 @@ function TestPageContainer({
234226
);
235227
}
236228

237-
const FormComponent = Form.create()(TestPageContainer);
238-
239229
export default connect(
240230
state => ({
241231
userinfo: state.app.userinfo, // 引入app model中的userinfo数据
@@ -248,4 +238,4 @@ export default connect(
248238
serverFetch: dispatch.test.serverFetch // 引入test model中的fetch异步请求action
249239
}
250240
})
251-
)(FormComponent);
241+
)(TestPageContainer);

src/container/testclass/index.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ class TestClassPageContainer extends React.Component {
2323
location: P.any, // 自动注入的location对象
2424
match: P.any, // 自动注入的match对象
2525
history: P.any, // 自动注入的history对象
26-
actions: P.object, // 上面model中定义的actions对象,自动成为this.props.actions变量
27-
form: P.any // antd的form表单高阶组件自动注入的form对象
26+
actions: P.object // 上面model中定义的actions对象,自动成为this.props.actions变量
2827
};
2928

3029
/** react生命周期 - 构造函数 **/
@@ -156,8 +155,6 @@ class TestClassPageContainer extends React.Component {
156155
}
157156

158157
render() {
159-
const { form } = this.props;
160-
161158
return (
162159
<div className="page-test-class">
163160
<h1 className="title">功能测试</h1>
@@ -300,7 +297,6 @@ class TestClassPageContainer extends React.Component {
300297
}
301298
}
302299

303-
const FormComponent = Form.create()(TestClassPageContainer);
304300
export default connect(
305301
state => ({
306302
userinfo: state.app.userinfo, // 引入app model中的userinfo数据
@@ -313,4 +309,4 @@ export default connect(
313309
serverFetch: model.test.serverFetch // 引入test model中的fetch异步请求action
314310
}
315311
})
316-
)(FormComponent);
312+
)(TestClassPageContainer);

0 commit comments

Comments
 (0)