How does vue elemnet-ui achieve a paged display of pictures like this?



figure: click "Select Photo" and pop up dialog
pop-up box to display a list of pictures with 8 pictures per page. I don"t know how this paging is realized?

The

code is as follows: (componentized)

Vue.component("select-photo",{
    props: ["param"],
    data: function () {
    return {
        currentPage:1,
        pagesize:4,
        isshow:false,
        imgs:[],
        selected:""
    }
  },
  methods: {
      openDialog(){
          var _this=this
          var param=this.param
          var sightId=param[3]
          if(sightId==""){
            this.$message({
                type: "info",
                message: ""
            }); 
          }else{
              axios.get("{:url("api/file/gallery")}"+"?limit=8&id="+sightId).then(function (response) {
                  if(response==""){
                      console.log("");
                  }else{
                      console.log(response.data.data);
                      Vue.set(_this,"imgs",response.data.data)
                      Vue.set(_this,"isshow",true)
                  }
                
            })
          }
          
      },
      selectedImg(imgsIndex){
          var img=(this.imgs[imgsIndex]["savepath"]+this.imgs[imgsIndex]["title"])
          Vue.set(this,"selected",img)
      },
      submitDialog(){
          var param=this.param
          var index=param[0]
          var i=param[1]
          var lasti=param[2]
          Vue.set(vm.tour[index].children[i].children[lasti],"img",this.selected)
        Vue.set(this,"isshow",false)
      }
  },
  template: "<div class="plan-button"><div @click="openDialog()"></div><el-dialog  title=""  :visible.sync="isshow"  width="600">  <div class="select_photo_container"><div class="row"><div class="photo_wrapper" v-for="(item,imgsIndex) in imgs"><img v-bind:src="(item.savepath+item.title)" v-on:click="selectedImg(imgsIndex)"><div class="img-checked" v-if="selected==(item.savepath+item.title)"><i class="iconfont icon-duigou"></i></div></div></div><div class="pagination"><el-pagination background layout="prev, pager, next" :current-page="currentPage" :page-size="pagesize"  :total="imgs.length"></el-pagination></div></div>  <span slot="footer" class="dialog-footer">    <el-button @click="isshow = false"> </el-button>    <el-button type="primary" @click="submitDialog"> </el-button>  </span></el-dialog></div>"
})

add: what is found on the Internet is table paging, mine is not table, direct div display of data, how to deal with it?

<el-table
   :data="data.slice((currentPage-1)*pagesize, currentPage*pagesize)"
   stripe
    border
    style="width: 100%">
May.25,2022

add paging component. When you click on paging, request the interface data to replace the current page image


paging has nothing to do with table. Table only maintains this data source.
the key is axios.get ("{: url ('api/file/gallery')}" + "? limit=8&id=" + sightId) this API should support paging
dialog when the first page is requested by default


you can refer to this example:

the key point of the problem is not stated. Besides, paging has nothing to do with table.
the key is whether the image data obtained by your axios.get ("{: url ('api/file/gallery')}" + "? limit=8&id=" + sightId) contains paging related information. If so, it is easy to do. If not, it is recommended that your back-end developers add that if they do not add you, you have to write code to get the number of pictures and do dynamic calculation of how many pages there are.


solve it by yourself, two solutions
the first one:
1, request the data on page 1 when clicking Dialog
2, and request

according to the current page when clicking on paging.
axios.get("{:url('api/file/gallery')}"+"?limit="+this.pagesize+"&id="+sightId+"&page="+currentPage)

the second scheme:
1. Request all data when you click Dialog

axios.get("{:url('api/file/gallery')}"+"?id="+sightId)

2. When you click paging, display

accordingly according to the following code
v-for="(item,index) in imgs.slice((currentPage-1)*pagesize,currentPage*pagesize)"
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3beb5-43bb9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3beb5-43bb9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?