Skip to content

Commit 404dab7

Browse files
committed
reducer修改和form表单
1 parent 08f8f75 commit 404dab7

File tree

6 files changed

+988
-11
lines changed

6 files changed

+988
-11
lines changed

config-overrides.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const { override, fixBabelImports } = require('customize-cra');
2+
3+
module.exports = override(
4+
fixBabelImports('import', {
5+
libraryName: 'antd',
6+
libraryDirectory: 'es',
7+
style: 'css',
8+
}),
9+
);

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
"@svgr/webpack": "4.3.2",
88
"@typescript-eslint/eslint-plugin": "1.13.0",
99
"@typescript-eslint/parser": "1.13.0",
10+
"antd": "^3.24.3",
1011
"babel-eslint": "10.0.2",
1112
"babel-jest": "^24.8.0",
1213
"babel-loader": "8.0.6",
14+
"babel-plugin-import": "^1.12.2",
1315
"babel-plugin-named-asset-import": "^0.3.3",
1416
"babel-preset-react-app": "^9.0.1",
1517
"camelcase": "^5.2.0",
1618
"case-sensitive-paths-webpack-plugin": "2.2.0",
1719
"css-loader": "2.1.1",
20+
"customize-cra": "^0.8.0",
1821
"dotenv": "6.2.0",
1922
"dotenv-expand": "4.2.0",
2023
"echarts": "^4.3.0",
@@ -45,6 +48,7 @@
4548
"postcss-safe-parser": "4.0.1",
4649
"react": "^16.9.0",
4750
"react-app-polyfill": "^1.0.2",
51+
"react-app-rewired": "^2.1.4",
4852
"react-dev-utils": "^9.0.2",
4953
"react-dom": "^16.9.0",
5054
"react-redux": "^7.1.1",

src/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@import '~antd/dist/antd.css';
12
body {
23
margin: 0;
34
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",

src/page/form/index.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import {
4+
Input, Form, Button,
5+
} from 'antd';
6+
7+
const { TextArea } = Input;
8+
// import req from '../../../req';
9+
10+
/**
11+
* 用户名弹窗
12+
*/
13+
function Page({form}) {
14+
const { getFieldDecorator, validateFields, getFieldValue } = form;
15+
function hasErrors(fieldsError) {
16+
return Object.keys(fieldsError).some(field => fieldsError[field]);
17+
}
18+
function onSubmit() {
19+
validateFields((err, val) => {
20+
console.log('value', val);
21+
if (err) {
22+
console.log(err);
23+
return;
24+
}
25+
console.log(val.text);
26+
});
27+
}
28+
return (
29+
<Form
30+
labelCol={{
31+
span: 6,
32+
}}
33+
wrapperCol={{
34+
span: 18,
35+
}}
36+
>
37+
<Form.Item label="原因:">
38+
{getFieldDecorator('text', {
39+
rules: [
40+
{ required: true, message: 'Please input your username!' },
41+
],
42+
})(
43+
<TextArea placeholder="请输入拒绝原因,必填" />,
44+
)}
45+
</Form.Item>
46+
<Button onClick={() => onSubmit()} disabled={getFieldValue('text') ? false : true }>提交</Button>
47+
</Form>
48+
)
49+
}
50+
51+
Page.propTypes = {
52+
form: PropTypes.object.isRequired,
53+
};
54+
55+
export default Form.create({ name: 'edit_cause' })(Page);

src/router/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import UseMemo from '../page/useMemo/index'
1414
import UseCallback from '../page/useCallback/index'
1515
import Memo from '../page/memoParent/index'
1616
import HeightEchart from '../page/heightEchart/index'
17+
import FormBox from '../page/form/index'
1718

1819
function Header() {
1920
return (
@@ -65,6 +66,9 @@ function Header() {
6566
<li>
6667
<Link to="/useCallback">hook之useCallback</Link>
6768
</li>
69+
<li>
70+
<Link to="/form">form表单</Link>
71+
</li>
6872
</ul>
6973
);
7074
}
@@ -91,6 +95,7 @@ function App() {
9195
<Route path="/useCallback" component={UseCallback} />
9296
<Route path="/memo" component={Memo} />
9397
<Route path="/heightEchart" component={HeightEchart} />
98+
<Route path="/form" component={FormBox} />
9499
</Switch>
95100
</div>
96101
</BrowserRouter>

0 commit comments

Comments
 (0)