javascript - 按页码跳转的分页下一个按钮 * 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)
}
解决方案
推荐阅读
- autopep8 - 是否可以自定义 autopep8 格式?
- ajax - p:dataTable 过滤值始终为空
- vue.js - vuetify v-slider 单击滑块后无法获得新位置
- opencv - “openface”没有属性“AlignDlib”
- javascript - SPFx 使用 pnp/sp 和命名问题通过 XML 创建字段
- filebeat - filebeat 配置:覆盖所有输入的 close_inactive 的默认值
- java - 方法没有被嘲笑
- javafx - .fxml 文件中的自定义类在混淆后不会被导入
- php - 如何在没有模型的 Yii 框架的下拉列表中添加指向所有选项的链接?
- c# - 尝试激活“”时无法解析类型“”的服务