<el-pagination background @current-change="changepage" :page-size="msg.limit" layout="total, prev, pager, next, jumper" :total="parseInt(msg.num)" :current-page.sync="msg.page">
</el-pagination>
js:
methods: {
changepage(currentPage,enter) {
if(enter && enter == 'enter')
{
var vm = this;
let oldCurrentPage = vm.msg.page;
let totalPages = Math.ceil(parseInt(vm.msg.num)/parseInt(vm.msg.limit));
if (currentPage > totalPages)
{
$('.is-in-pagination .el-input__inner').val(totalPages);
currentPage = totalPages;
}
if (currentPage) {//判空
//新旧页码对比没有变化或者超过总页数不做处理
if (oldCurrentPage != currentPage && currentPage <= totalPages) {
vm.$emit('fatherchange', currentPage);
document.getElementById("scroller-box").children[0].scrollTop = 0;
}
}
}
else
{
var vm = this;
var timer = null;
// this.$parent.fatherchange(e);
this.$emit('fatherchange', currentPage)
document.getElementById("scroller-box").children[0].scrollTop = 0;
}
}
},
mounted(){
var vm = this;
document.onkeydown = function(e){
let key = window.event.keyCode;
if(key == '13'){
let value = parseInt($('.is-in-pagination .el-input__inner').val());
vm.changepage(value,'enter');
}
}
}
网友评论