Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
taroMeeting
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fengzhaoyu
taroMeeting
Commits
9291f0c9
Commit
9291f0c9
authored
Sep 28, 2018
by
王树冬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opt action
parent
9bfdecc7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
57 deletions
+95
-57
counter.js
src/actions/counter.js
+2
-57
oldback.js
src/actions/oldback.js
+93
-0
No files found.
src/actions/counter.js
View file @
9291f0c9
...
...
@@ -28,63 +28,8 @@ export function asyncAdd() {
},
2000
)
}
}
// 异步的action
// export function list() {
// return dispatch => {
// Taro.request({
// url: 'http://api.shudong.wang/v1/article/list',
// data: {
// foo: 'foo',
// bar: 10
// },
// header: {
// 'content-type': 'application/json'
// }
// })
// // .then(res => console.log(res.data))
// }
// }
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
))
})
}
}
// export const list = createApiAction(LIST, params => Taro.request({
// url: 'http://api.shudong.wang/v1/article/list',
// data: params,
// header: {
// 'content-type': 'application/json'
// }
// }))
// export const list = createApiAction(LIST, params => api.get('news/list', params))
export
const
list
=
createApiAction
(
LIST
,
params
=>
{
console
.
log
(
'list'
,
params
);
return
api
.
get
(
'NervJS/taro/issues'
,
params
)
})
// 请求api
export
const
list
=
createApiAction
(
LIST
,
params
=>
api
.
get
(
'NervJS/taro/issues'
,
params
))
export
default
bindActionCreators
({
list
,
add
,
...
...
src/actions/oldback.js
0 → 100644
View file @
9291f0c9
import
{
bindActionCreators
}
from
'redux'
import
Taro
from
'@tarojs/taro'
import
{
ADD
,
LIST
,
MINUS
}
from
'../constants/counter'
import
store
from
'../store'
import
{
createApiAction
}
from
'./index'
import
api
from
'../service/api'
export
const
add
=
()
=>
{
return
{
type
:
ADD
}
}
export
const
minus
=
()
=>
{
return
{
type
:
MINUS
}
}
// 异步的action
export
function
asyncAdd
()
{
return
dispatch
=>
{
setTimeout
(()
=>
{
dispatch
(
add
())
},
2000
)
}
}
// 异步的action
// export function list() {
// return dispatch => {
// Taro.request({
// url: 'http://api.shudong.wang/v1/article/list',
// data: {
// foo: 'foo',
// bar: 10
// },
// header: {
// 'content-type': 'application/json'
// }
// })
// // .then(res => console.log(res.data))
// }
// }
// 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))
// })
// }
// }
// export const list = createApiAction(LIST, params => Taro.request({
// url: 'http://api.shudong.wang/v1/article/list',
// data: params,
// header: {
// 'content-type': 'application/json'
// }
// }))
// export const list = createApiAction(LIST, params => api.get('news/list', params))
export
const
list
=
createApiAction
(
LIST
,
params
=>
{
console
.
log
(
'list'
,
params
);
return
api
.
get
(
'NervJS/taro/issues'
,
params
)
})
export
default
bindActionCreators
({
list
,
add
,
minus
,
asyncAdd
},
store
.
dispatch
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment