element-ui封装分页组件







import pagination from '../../components/Pagination.vue'
data() {
      return {
        currentPage: 1,
        pagesize: 10,
        total: 0
      }
 },
methods:{
        handleCurrentChange(val) {
           this.currentPage = val;
           this.All_data(this.currentPage,this.pagesize);
        },
        handleSizeChange(val) {
           this.pagesize = val;
           this.currentPage = 1;    //这里选择每页多少数据,重置页码为1
           this.All_data(this.currentPage,this.pagesize);
        },
        All_data(page,size){
         let data = {
           "page":page,
           "size":size
         }
         // this.tableData = []
         this.$axios.post(this.$url + '/master/comment/bypage',data)
           .then((res) => {
             // console.log(res.data.pojo.list)
             this.total = res.data.pojo.total
             this.tableData = res.data.pojo.list
           })
           .catch((res) => {
             console.log(res)
           })
       },
},
created() {
       this.All_data(this.currentPage,this.pagesize)
}

你可能感兴趣的:(element-ui封装分页组件)