Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
28958fa0
Commit
28958fa0
authored
Nov 10, 2016
by
furybean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pagination: fix current-change emit too many.
parent
72a66e8c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
examples/docs/zh-CN/pagination.md
examples/docs/zh-CN/pagination.md
+1
-1
packages/pagination/src/pagination.js
packages/pagination/src/pagination.js
+13
-5
test/unit/specs/pagination.spec.js
test/unit/specs/pagination.spec.js
+2
-2
No files found.
examples/docs/zh-CN/pagination.md
View file @
28958fa0
...
...
@@ -186,7 +186,7 @@
| small | 是否使用小型分页样式 | Boolean | — | false |
| page-size | 每页显示条目个数 | Number | — | 10 |
| total | 总条目数 | Number | — | - |
| page-count | 总页数,total 和 page-count 设置任意一个就可以达到显示页码的功能
如果要支持 page-sizes 的更改,则需要使用 total 属性
;如果要支持 page-sizes 的更改,则需要使用 total 属性 | Number | — | - |
| page-count | 总页数,total 和 page-count 设置任意一个就可以达到显示页码的功能;如果要支持 page-sizes 的更改,则需要使用 total 属性 | Number | — | - |
| current-page | 当前页数 | Number | — | 1 |
| layout | 组件布局,子组件名用逗号分隔| String |
`sizes`
,
`prev`
,
`pager`
,
`next`
,
`jumper`
,
`->`
,
`total`
| 'prev, pager, next, jumper, ->, total' |
| page-sizes | 每页显示个数选择器的选项设置 | Number
[]
| — |
[
10, 20, 30, 40, 50, 100
]
|
...
...
packages/pagination/src/pagination.js
View file @
28958fa0
...
...
@@ -174,8 +174,11 @@ export default {
},
handleChange
({
target
})
{
const
oldPage
=
this
.
$parent
.
internalCurrentPage
;
this
.
$parent
.
internalCurrentPage
=
this
.
$parent
.
getValidCurrentPage
(
target
.
value
);
if
(
oldPage
!==
this
.
$parent
.
internalCurrentPage
)
{
this
.
$parent
.
$emit
(
'
current-change
'
,
this
.
$parent
.
internalCurrentPage
);
}
this
.
oldValue
=
null
;
}
},
...
...
@@ -225,8 +228,11 @@ export default {
},
handleCurrentChange
(
val
)
{
const
oldPage
=
this
.
internalCurrentPage
;
this
.
internalCurrentPage
=
this
.
getValidCurrentPage
(
val
);
if
(
oldPage
!==
this
.
internalCurrentPage
)
{
this
.
$emit
(
'
current-change
'
,
this
.
internalCurrentPage
);
}
},
prev
()
{
...
...
@@ -289,11 +295,13 @@ export default {
watch
:
{
internalPageCount
(
newVal
)
{
/* istanbul ignore if */
if
(
newVal
>
0
&&
this
.
internalCurrentPage
===
0
)
{
const
oldPage
=
this
.
internalCurrentPage
;
if
(
newVal
>
0
&&
oldPage
===
0
)
{
this
.
internalCurrentPage
=
1
;
this
.
$emit
(
'
current-change
'
,
1
);
}
else
if
(
this
.
internalCurrentPage
>
newVal
)
{
}
else
if
(
oldPage
>
newVal
)
{
this
.
internalCurrentPage
=
newVal
===
0
?
1
:
newVal
;
}
if
(
oldPage
!==
this
.
internalCurrentPage
)
{
this
.
$emit
(
'
current-change
'
,
this
.
internalCurrentPage
);
}
},
...
...
test/unit/specs/pagination.spec.js
View file @
28958fa0
...
...
@@ -142,7 +142,7 @@ describe('Pagination', () => {
},
data
()
{
return
{
page
:
0
};
return
{
page
:
1
};
}
},
true
);
const
input
=
vm
.
$el
.
querySelector
(
'
.el-pagination__jump input
'
);
...
...
@@ -228,7 +228,7 @@ describe('Pagination', () => {
},
data
()
{
return
{
page
:
0
};
return
{
page
:
1
};
}
});
const
input
=
vm
.
$el
.
querySelector
(
'
.el-pagination__jump input
'
);
...
...
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