there are several places on the page that need to be paged. A paging component is written with vue. The data source obtained from the background is different in each place. The paging components are as follows:
components:{
"page-bar":{
data(){
return {
all: "", //
cur: 1,//
}
},
btnClick: function(data){//
let _this=this;
if(data != this.cur){
this.cur = data
};
_this.search(data-1);
},
pageClick: function(){
let _this=this;
console.log(""+this.cur+"");
_this.search(_this.cur-1);
},
computed: {
indexs: function(){
var left = 1;
var right = this.all;
var ar = [];
if(this.all>= 5){
if(this.cur > 3 && this.cur < this.all-2){
left = this.cur - 2
right = this.cur + 2
}else{
if(this.cur<=3){
left = 1
right = 5
}else{
right = this.all
left = this.all -4
}
}
}
while (left <= right){
ar.push(left)
left PP
}
return ar
}
},
template:`<div class="page-bar">
<ul>
<li v-if="cur>1"><a v-on:click="cur--,pageClick()"></a></li>
<li v-if="cur==1"><a class="banclick"></a></li>
<li v-for="index in indexs" v-bind:class="{ "active": cur == index}">
<a v-on:click="btnClick(index)">{{ index }}</a>
</li>
<li v-if="cur!=all"><a v-on:click="curPP,pageClick()"></a></li>
<li v-if="cur == all"><a class="banclick"></a></li>
<li><a><i>{{all}}</i></a></li>
</ul>
</div>`
}
}
The search methods of btnclick and pageclick are used to call different data paging api, so if I call the same api when I call < page-bar > < page-bar > everywhere, is there any way to distinguish