我的分页问题。它似乎取了我所在页面的数量,并在点击“下一个数组”箭头函数IE时将其乘以6:“点击第二页然后下一个箭头功能它跳转到第13-18页而不是跳到第7-12页。
second array clicking arrow buttons after click on page two jumps to the wrong section
这是创建分页的代码。
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)
}