首页 > 解决方案 > 按页码跳转的分页下一个按钮 * 6

问题描述

我的分页有问题。单击“下一个数组”箭头函数 IE 时,似乎将我所在的页面数乘以 6:“单击第二页然后下一个箭头函数跳转到第 13-18 页而不是跳转到第 7-12 页。

下一个按钮,第一个数组

单击第二页后第二个数组单击箭头按钮跳转到错误的部分

这是创建分页的代码。

CreatePages() {
    this.pages = [];
    console.log({'this.iteration':this.iteration,'this.iteration * 6 - 6':this.iteration * 6 - 6,'this.iteration * 6':this.iteration * 6,'this.allPages':this.allPages})

    for (var i = this.iteration * 6 - 6; i < this.iteration * 6 && i < this.allPages; i++) //populate the pages array
    {
      console.log({'this.iteration':this.iteration,'(this.iteration - 1) * 6':(this.iteration - 1) * 6})
      if (i == (this.iteration - 1) ) {
        this.pages.push({ id: i + 1, current: true });
      }
      else
        this.pages.push({ id: i + 1, current: false });
    }
console.log({pages:this.pages})
  }
  
  

age(id: number) {

    this.pages.forEach(function (p) {

      if (p.id != id)
        p.current = false;
      else
        p.current = true;
    })
this.iteration =id;
this.postSearch(this.query,this.iteration,this.pagesize,this.categories)

  }

  PagingPrev() {
    this.iteration--;
    if (this.iteration <= 0) {
      this.iteration = 1;
    }
    else
      this.CreatePages();

    this.Page(this.iteration)
  }

  PagingNext() {
    this.iteration++;
    if (this.iteration > Math.ceil(this.allPages / 1)) {
      this.iteration = Math.ceil(this.allPages / 6);
    }
    else{
      this.CreatePages();
    }
    console.log({"mattspages":this.iteration})
     
    this.Page(this.iteration)
    
  }

标签: javascriptangulartypescript

解决方案


推荐阅读