Commit 55a25d5b by 马贞晓

radme

1 parent a8076eb1
Showing 1 changed file with 11 additions and 4 deletions
### 运行 ### 运行
```java ```
yarn start yarn start
npm run start //开发 npm run start //开发
yarn build yarn build
npm run build //打包 npm run build //打包
``` ```
### 依赖 ### 依赖
* axios * axios
...@@ -13,6 +15,7 @@ ...@@ -13,6 +15,7 @@
* react-router-dom * react-router-dom
#### axios 使用 #### axios 使用
> service中重新定义GET POST > service中重新定义GET POST
``` javascript ``` javascript
import $http from "../../service"; //页面引入统一service import $http from "../../service"; //页面引入统一service
$http.GET("/test") $http.GET("/test")
...@@ -23,9 +26,11 @@ import $http from "../../service"; //页面引入统一service ...@@ -23,9 +26,11 @@ import $http from "../../service"; //页面引入统一service
debugger debugger
}) })
``` ```
#### redux 使用 #### redux 使用
>页面引入redux的connct,采用装饰器模式过滤所需state >页面引入redux的connct,采用装饰器模式过滤所需state
```javascript
``` javascript
import{connect} from "react-redux"; import{connect} from "react-redux";
@connect((state)=>{ @connect((state)=>{
// debugger // debugger
...@@ -35,9 +40,10 @@ import $http from "../../service"; //页面引入统一service ...@@ -35,9 +40,10 @@ import $http from "../../service"; //页面引入统一service
class Demo extends Component{} class Demo extends Component{}
``` ```
> 页面修改redux,type类型为枚举类型,防止胡乱定义 > 页面修改redux,type类型为枚举类型,防止胡乱定义
```javascript ``` javascript
import EVENT from "../../store/EVENT" import EVENT from "../../store/EVENT"
this.props.dispatch({ this.props.dispatch({
type:EVENT.LOGIN, type:EVENT.LOGIN,
...@@ -49,7 +55,8 @@ import EVENT from "../../store/EVENT" ...@@ -49,7 +55,8 @@ import EVENT from "../../store/EVENT"
#### react-router-dom #### react-router-dom
> 页面中引入路由跳转,使用Link组件跳转和动态跳转 > 页面中引入路由跳转,使用Link组件跳转和动态跳转
```javascript
``` javascript
import {Link} from "react-router-dom"; //组件跳转 import {Link} from "react-router-dom"; //组件跳转
this.props.history.push("/index2") //动态跳转 this.props.history.push("/index2") //动态跳转
``` ```
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!