Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
hfpp2012
/
react-spd
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5dd3a784
authored
Jun 08, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
删除最后一个元素
1 parent
328e72f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
6 deletions
src/actions/headergroup.js
src/components/ElementGroup.js
src/reducers/headergroup.js
src/actions/headergroup.js
View file @
5dd3a78
...
@@ -6,3 +6,7 @@ export const cloneElement = (element) => ({
...
@@ -6,3 +6,7 @@ export const cloneElement = (element) => ({
export
const
deleteLastElement
=
()
=>
({
export
const
deleteLastElement
=
()
=>
({
type
:
'DELETE_LAST_ELEMENT'
type
:
'DELETE_LAST_ELEMENT'
})
})
export
const
deleteElement
=
()
=>
({
type
:
'DELETE_ELEMENT'
})
src/components/ElementGroup.js
View file @
5dd3a78
...
@@ -14,12 +14,6 @@ class ElementGroup extends React.Component {
...
@@ -14,12 +14,6 @@ class ElementGroup extends React.Component {
this
.
setState
({
elements
:
elements
})
this
.
setState
({
elements
:
elements
})
}
}
// 返回element的index为-1, 删除最后一个元素
deleteLastElement
()
{
const
elements
=
ReactAddonsUpdate
(
this
.
state
.
elements
,
{
$splice
:
[[
-
1
,
1
]]
})
this
.
setState
({
elements
:
elements
})
}
sidebar
()
{
sidebar
()
{
return
document
.
getElementById
(
'sidebar'
)
return
document
.
getElementById
(
'sidebar'
)
}
}
...
...
src/reducers/headergroup.js
View file @
5dd3a78
...
@@ -11,6 +11,10 @@ const headergroup = (state = init_state, action) => {
...
@@ -11,6 +11,10 @@ const headergroup = (state = init_state, action) => {
...
state
,
...
state
,
action
.
element
action
.
element
]
]
case
'DELETE_LAST_ELEMENT'
:
return
[
...
state
.
slice
(
0
,
-
1
),
]
default
:
default
:
return
state
return
state
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment