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
258b90c3
Commit
258b90c3
authored
6 years ago
by
王树冬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新获取状态的写法
parent
9291f0c9
master
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
27 deletions
+32
-27
changelog.md
changelog.md
+2
-0
app.js
src/app.js
+1
-1
index.js
src/pages/index/index.js
+28
-22
index.js
src/store/index.js
+1
-4
No files found.
changelog.md
0 → 100644
View file @
258b90c3
## 2018年11月26日
优化action 代码
This diff is collapsed.
Click to expand it.
src/app.js
View file @
258b90c3
...
...
@@ -8,7 +8,7 @@ import configStore from './store'
import
'./app.styl'
const
store
=
configStore
()
const
store
=
configStore
class
App
extends
Component
{
...
...
This diff is collapsed.
Click to expand it.
src/pages/index/index.js
View file @
258b90c3
...
...
@@ -2,7 +2,8 @@ import Taro, { Component } from '@tarojs/taro'
import
{
View
,
Button
,
Text
}
from
'@tarojs/components'
import
{
connect
}
from
'@tarojs/redux'
import
{
add
,
minus
,
asyncAdd
,
list
}
from
'../../actions/counter'
// import { add, minus, asyncAdd, list } from '../../actions/counter'
import
counterAction
from
'../../actions/counter'
import
'./index.styl'
...
...
@@ -23,16 +24,18 @@ import './index.styl'
// // dispatch(list())
// // }
// }))
@
connect
(
state
=>
({
list
:
state
.
counter
.
list
,
}),
(
dispatch
)
=>
({
getList
(
params
)
{
dispatch
(
list
(
params
))
}
})
)
// @connect(
// state => ({
// list: state.counter.list,
// }),
// (dispatch) => ({
// getList(params) {
// dispatch(list(params))
// }
// })
// )
class
Index
extends
Component
{
config
=
{
...
...
@@ -40,7 +43,6 @@ class Index extends Component {
}
constructor
(
props
)
{
super
(
props
)
console
.
log
(
'props'
,
props
);
// this.state = { date: new Date() }
// let params = {
// page: 2, per_page: 2
...
...
@@ -49,14 +51,14 @@ class Index extends Component {
page
:
1
,
per_page
:
10
}
if
(
Object
.
keys
(
props
).
length
===
0
)
return
props
.
getL
ist
(
this
.
state
)
counterAction
.
l
ist
(
this
.
state
)
}
componentWillReceiveProps
(
nextProps
)
{
console
.
log
(
this
.
props
,
nextProps
)
}
componentWillMount
()
{
console
.
log
(
'thisprops'
,
this
.
props
);
this
.
props
.
getL
ist
(
this
.
state
)
// this.props.getList(this.state)
counterAction
.
l
ist
(
this
.
state
)
}
componentWillUnmount
()
{
...
...
@@ -68,13 +70,13 @@ class Index extends Component {
onShareAppMessage
()
{
return
{
title
:
'
蜂窝煤
'
,
title
:
'
taro issue
'
,
path
:
'/pages/index/index'
,
imageUrl
:
'../../common/image/share.png'
}
}
onReachBottom
()
{
console
.
log
(
'触发到底部了'
)
// 触发到底部
this
.
setState
({
page
:
this
.
state
.
page
+
1
})
...
...
@@ -82,16 +84,16 @@ class Index extends Component {
let
params
=
{
page
:
this
.
state
.
page
+
1
,
per_page
:
per_page
}
console
.
log
(
this
.
props
,
'onReachBottom'
)
this
.
props
.
getList
(
params
)
counterAction
.
list
(
params
)
}
render
()
{
if
(
!
this
.
props
.
getList
)
return
return
(
<
View
className
=
'index'
>
<
View
className
=
'data'
>
数据列表
<
/View
>
<
View
className
=
'news'
>
{
this
.
props
.
l
ist
.
map
((
item
,
index
)
=>
{
this
.
props
.
getL
ist
.
map
((
item
,
index
)
=>
{
return
<
View
className
=
'item'
key
=
{
index
}
>
<
View
className
=
'info'
>
<
View
className
=
'title'
>
{
item
.
title
}
<
/View
>
...
...
@@ -109,5 +111,9 @@ class Index extends Component {
)
}
}
export
default
Index
const
mapStateToProps
=
(
state
,
ownProps
)
=>
{
return
{
getList
:
state
.
counter
.
list
}
}
export
default
connect
(
mapStateToProps
)(
Index
)
This diff is collapsed.
Click to expand it.
src/store/index.js
View file @
258b90c3
...
...
@@ -8,7 +8,4 @@ const middlewares = [
createLogger
()
]
export
default
function
configStore
()
{
const
store
=
createStore
(
rootReducer
,
applyMiddleware
(...
middlewares
))
return
store
}
export
default
createStore
(
rootReducer
,
applyMiddleware
(...
middlewares
))
This diff is collapsed.
Click to expand it.
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