Commit 144bfde2 by 王树冬

init

parent 19710804
{ {
"name": "demo", "name": "taro-kit",
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"description": "demo", "description": "taro kit",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build:weapp": "taro build --type weapp", "build:weapp": "taro build --type weapp",
......
## 功能列表 ## 功能列表
[*] 增加createApiAction * [] 封装api请求方式
[*] 封装api请求方式 * [] 更方便的创建action:增加createApiAction
* [] 基础像素试着为1倍即:1px 会编译成 2rpx(小程序默认是2倍)符合习惯
* [] 基础demo案列
#### 更方面的创建action
> 未封装前
```
function articleList(data) {
return { type: LIST, payload: data }
}
export function list() {
console.log('list')
return (dispatch) => {
// service.get('/v1/article/list')
// .then((res) => {
// dispatch(articleList(res.data.article))
// })
Taro.request({
url: 'http://api.shudong.wang/v1/article/list',
data: {
foo: 'foo',
bar: 10
},
header: {
'content-type': 'application/json'
}
}).then((res) => {
dispatch(articleList(res.data.article))
})
}
}
```
![2018-09-25-15-50-45](http://file.shudong.wang/2018-09-25-15-50-45.png)
> 封装后请求api的使用方式
```
export const list = createApiAction(LIST, params => api.get('news/list', params))
```
![2018-09-25-15-51-45](http://file.shudong.wang/2018-09-25-15-51-45.png)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment