Element Pagination 分页请求两次接口BUG解决--测试可用!!!
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
·
前言:element Ui 分页size-change事件触发同时也出发了current-change事件
bug:当选择最后至一页切换条数就会请求两次接口
1:选择最后一页(第2页)

2:切换条数会请求两次接口

解决方法:定义变量state默认为true;条数改变的时候@current-change事件则不请求接口,这样的话只请求了@size-change事件的接口请求、
<el-pagination center background :pager-count="5" layout="prev, pager, next, sizes" :page-sizes="[10,20,50]"
:page-size="pagesize" :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange">
</el-pagination>
data(){
return{
dataObj: {
token: this.$store.getters.token,
index: 1,
length: 10
},
total:0,
currpage: 1,
pagesize: 10,
total:0,//条数的总数
state:true,
}
}
methods:{
getData() {
接口请求....
api().then(res=>{
请求成功...
this.state=true;
this.total = res.max; //条数的总数
})
},
handleCurrentChange(cpage) { //页数
// console.log(cpage)
this.currpage = cpage;
this.dataObj.index = cpage;
if(this.state==true){
this.getData()
}
},
handleSizeChange(psize) { //条数
// console.log(psize)
this.state=false;
this.pagesize = psize;
this.dataObj.length = psize
if(this.state==false){
this.getData()
}
},
}
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:2 个月前 )
c345bb45
1 年前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 1 年前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)