element ui 上一页下一页_vue翻页器,包括上一页,下一页,跳转

翻页组件 -- 子组件

上一页

{{i}}

{{i}}

{{i}}

下一页

跳转到:

GO

export default {

model: { // 通过v-model传过来的参数

prop: 'pageNo',

event: 'jumpPage'

},

props: {

pageSize: {

type: Number,

default: 1

},

pageNo: { // 通过v-model传过来的参数

type: Number,

default: 1

}

},

data () {

return {

jumpPage: '' // 避免操作props参数

}

},

computed: {

prevDisable: function () { // “上一页”按钮是否可点

if (this.pageNo > 1) {

return false

} else {

return true

}

},

nextDisable: function () { // “下一页”按钮是否可点

if (this.pageNo < this.pageSize && this.pageSize > 1) {

return false

} else {

return true

}

}

},

methods: {

jumpPrev: function () { // 点击上一页

if (this.pageNo === 1) {

return false

} else {

this.$emit('jumpPage', this.pageNo - 1)

}

},

jumpNext: function () { // 点击下一页

if (this.pageNo === this.pageSize) {

return false

} else {

this.$emit('jumpPage', this.pageNo + 1) // 修改当前页码

}

},

jump: function (id) { // 直接跳转

if (id > this.pageSize) {

id = this.pageSize

}

this.jumpPage = ''

this.$emit('jumpPage', id) // 修改当前页码

},

Go: function () {

if (this.jumpPage === '') { // 判空处理

return false

} else if (/^\d*$/.test(parseInt(this.jumpPage))) { // 填写数字才能跳转

this.jump(parseInt(this.jumpPage))

this.jumpPage = ''

} else {

this.jumpPage = ''

return false

}

}

}

}

@import "~styles/varibles.styl"

.pager-wrapper

float right

display flex

flex-direction row

height 38px

.pager-box

margin-top -15px

a,span

display inline-block

width 38px

height 38px

margin 0 2px

border 1px solid #E5E5E5

color #bdbdbd

text-align center

font 14px/38px ""

em

color $bgColor

.pager-prev,.pager-next

width 78px

.pager-input

display flex

flex-direction row

height 38px

margin-left 20px

font 14px/40px ""

color #bdbdbd

input,.pager-btn-go

display inline-block

width 40px

height 40px

border 1px solid #E5E5E5

box-sizing content-box

outline none

text-align center

父组件

//组件引入

import pager from '../../component/pager/pager.vue'

//组件调用声明

components:{ pager}

//参数

data () {

return {

pageSize: 30, //总页数 -- 后台传值

pageNo: 2  //当前页

}

}

//接收跳转事件

methods:{

jump (id) {

console.log(id)

}

}

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值