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
Nov 26, 2018
by
王树冬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新获取状态的写法
parent
9291f0c9
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 代码
src/app.js
View file @
258b90c3
...
@@ -8,7 +8,7 @@ import configStore from './store'
...
@@ -8,7 +8,7 @@ import configStore from './store'
import
'./app.styl'
import
'./app.styl'
const
store
=
configStore
()
const
store
=
configStore
class
App
extends
Component
{
class
App
extends
Component
{
...
...
src/pages/index/index.js
View file @
258b90c3
...
@@ -2,7 +2,8 @@ import Taro, { Component } from '@tarojs/taro'
...
@@ -2,7 +2,8 @@ import Taro, { Component } from '@tarojs/taro'
import
{
View
,
Button
,
Text
}
from
'@tarojs/components'
import
{
View
,
Button
,
Text
}
from
'@tarojs/components'
import
{
connect
}
from
'@tarojs/redux'
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'
import
'./index.styl'
...
@@ -23,16 +24,18 @@ import './index.styl'
...
@@ -23,16 +24,18 @@ import './index.styl'
// // dispatch(list())
// // dispatch(list())
// // }
// // }
// }))
// }))
@
connect
(
state
=>
({
list
:
state
.
counter
.
list
,
// @connect(
}),
// state => ({
(
dispatch
)
=>
({
// list: state.counter.list,
getList
(
params
)
{
// }),
dispatch
(
list
(
params
))
// (dispatch) => ({
}
// getList(params) {
})
// dispatch(list(params))
)
// }
// })
// )
class
Index
extends
Component
{
class
Index
extends
Component
{
config
=
{
config
=
{
...
@@ -40,7 +43,6 @@ class Index extends Component {
...
@@ -40,7 +43,6 @@ class Index extends Component {
}
}
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
)
super
(
props
)
console
.
log
(
'props'
,
props
);
// this.state = { date: new Date() }
// this.state = { date: new Date() }
// let params = {
// let params = {
// page: 2, per_page: 2
// page: 2, per_page: 2
...
@@ -49,14 +51,14 @@ class Index extends Component {
...
@@ -49,14 +51,14 @@ class Index extends Component {
page
:
1
,
per_page
:
10
page
:
1
,
per_page
:
10
}
}
if
(
Object
.
keys
(
props
).
length
===
0
)
return
if
(
Object
.
keys
(
props
).
length
===
0
)
return
props
.
getL
ist
(
this
.
state
)
counterAction
.
l
ist
(
this
.
state
)
}
}
componentWillReceiveProps
(
nextProps
)
{
componentWillReceiveProps
(
nextProps
)
{
console
.
log
(
this
.
props
,
nextProps
)
console
.
log
(
this
.
props
,
nextProps
)
}
}
componentWillMount
()
{
componentWillMount
()
{
console
.
log
(
'thisprops'
,
this
.
props
);
// this.props.getList(this.state)
this
.
props
.
getL
ist
(
this
.
state
)
counterAction
.
l
ist
(
this
.
state
)
}
}
componentWillUnmount
()
{
componentWillUnmount
()
{
...
@@ -68,13 +70,13 @@ class Index extends Component {
...
@@ -68,13 +70,13 @@ class Index extends Component {
onShareAppMessage
()
{
onShareAppMessage
()
{
return
{
return
{
title
:
'
蜂窝煤
'
,
title
:
'
taro issue
'
,
path
:
'/pages/index/index'
,
path
:
'/pages/index/index'
,
imageUrl
:
'../../common/image/share.png'
imageUrl
:
'../../common/image/share.png'
}
}
}
}
onReachBottom
()
{
onReachBottom
()
{
console
.
log
(
'触发到底部了'
)
// 触发到底部
this
.
setState
({
this
.
setState
({
page
:
this
.
state
.
page
+
1
page
:
this
.
state
.
page
+
1
})
})
...
@@ -82,16 +84,16 @@ class Index extends Component {
...
@@ -82,16 +84,16 @@ class Index extends Component {
let
params
=
{
let
params
=
{
page
:
this
.
state
.
page
+
1
,
per_page
:
per_page
page
:
this
.
state
.
page
+
1
,
per_page
:
per_page
}
}
console
.
log
(
this
.
props
,
'onReachBottom'
)
counterAction
.
list
(
params
)
this
.
props
.
getList
(
params
)
}
}
render
()
{
render
()
{
if
(
!
this
.
props
.
getList
)
return
return
(
return
(
<
View
className
=
'index'
>
<
View
className
=
'index'
>
<
View
className
=
'data'
>
数据列表
<
/View
>
<
View
className
=
'data'
>
数据列表
<
/View
>
<
View
className
=
'news'
>
<
View
className
=
'news'
>
{
{
this
.
props
.
l
ist
.
map
((
item
,
index
)
=>
{
this
.
props
.
getL
ist
.
map
((
item
,
index
)
=>
{
return
<
View
className
=
'item'
key
=
{
index
}
>
return
<
View
className
=
'item'
key
=
{
index
}
>
<
View
className
=
'info'
>
<
View
className
=
'info'
>
<
View
className
=
'title'
>
{
item
.
title
}
<
/View
>
<
View
className
=
'title'
>
{
item
.
title
}
<
/View
>
...
@@ -109,5 +111,9 @@ class Index extends Component {
...
@@ -109,5 +111,9 @@ class Index extends Component {
)
)
}
}
}
}
const
mapStateToProps
=
(
state
,
ownProps
)
=>
{
export
default
Index
return
{
getList
:
state
.
counter
.
list
}
}
export
default
connect
(
mapStateToProps
)(
Index
)
src/store/index.js
View file @
258b90c3
...
@@ -8,7 +8,4 @@ const middlewares = [
...
@@ -8,7 +8,4 @@ const middlewares = [
createLogger
()
createLogger
()
]
]
export
default
function
configStore
()
{
export
default
createStore
(
rootReducer
,
applyMiddleware
(...
middlewares
))
const
store
=
createStore
(
rootReducer
,
applyMiddleware
(...
middlewares
))
return
store
}
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