1. Preparation of project development
- Item Description
- Technology Selection
- api Interface (Part 4: 3 {URL request, the request mode, format parameter request}, in response to a data format) / interface document / test interface
2. Start project development
- Create a project using scaffolding react
- Development environment running: npm start
- Packaging production run: npm run build serve build
3. git project management
- Creating a remote repository
- Create a local warehouse
- Configuration .gitignore
- git init
- git add .
- git commit -m "init"
- The local repository pushed to the remote repository
- git remote add origin url
- git push origin master
- Create a dev branch locally, and pushed to the remote
- gitcheckout -b dev
- git push origin dev
- If there are local modifications
- git add.
- git commit -m "xxx"
- git push origin dev
- At the same time new: Clone warehouse
- git clone url
- git checkout -b dev origin/dev
- git pull origin dev
- If the remote modification
- git pull origin dev
4. Create the basic structure of the project
api: ajax request module
components: non-routing component
pages: grounds assembly
app.js: root component applications
index.js: Entrance js
The introduction antd
Download antd package (npm i antd -d)
Demand Packing: Packing only import component introduced js / css
Download Kit (npm i react-app-rewired customize-cra babel-plugin-import)
config-overrides.js
package.jason
Custom Theme
Download Kit (npm i less less-loader -d)
config-overrides.js
Use of components antd
According to a document prepared by antd
6. import routes
Download: react-router-dom
Split Application Route:
Login: Log
Admin: admin interface
Registration route:
<BrowserRouter> // router
<Switch> // switch wherein a route
<Route path = '' component = {} /> // Route
7. Login static components
- Custom style layout part
- Use antd component implementation login form interface
- Form / Form.Item
- Input
- Icon
- Button
8. The collection form data and forms the reception authentication
1. form objects
How to make components contain <Form> is obtained form the object?
WrapLoginForm = Form.create()(LoginForm)
WrapLoginForm is LoginForm parent component, it gives LoginForm incoming form properties, uses technology and higher-order components of higher-order functions
2. Operation Form Data
form.getFiledDecorator ( 'identification name', {initialValue: Initial value, rules: []}) (<Input />) packaging table item tag assembly
form.getFieldsValue (); to give the object contains all the input data
form.getFieldValue (id); obtained according to the identification data corresponding to the input field
3. Reception Form Validation
1. Declare real-time form validation
form.getFieldDecorator ( 'identification name', {rules: [{min: 4, message: 'error message'}]}) (<Input />)
2. Custom form validation
form.getFieldDecorator('标识名称',{rules:{validator:this.validatePwd}})(<Input/>) validatePwd = (rule,value,callback)=>{ IF (problem) callback ( 'error') the else callback () }
3. Click unified verification tips
form.validateFields ((error, values) => { IF (! error) {verified, send a request} ajax })
9. The higher order components and higher-order functions