VueJs how to make pagination with limiter and range..?

前端 未结 2 794
-上瘾入骨i
-上瘾入骨i 2020-12-13 07:15

I have code like this :



        
2条回答
  •  Happy的楠姐
    2020-12-13 08:11

    I've forked @Jeff's code and make a working version for Vue 2 due to this filter migration https://vuejs.org/v2/guide/migration.html#Filters-Outside-Text-Interpolations-removed.

    paginate method is moved to computed:

    paginate: function() {
            if (!this.users || this.users.length != this.users.length) {
                return
            }
            this.resultCount = this.users.length
            if (this.currentPage >= this.totalPages) {
              this.currentPage = this.totalPages
            }
            var index = this.currentPage * this.itemsPerPage - this.itemsPerPage
            return this.users.slice(index, index + this.itemsPerPage)
        }
    

    WARNING: I didn't apply the text filter, just the pagination first.

    https://jsfiddle.net/c1ghkw2p/

提交回复
热议问题