elementUI 페이지 나누기 방법

4498 단어 vue.js
template 쓰기
  
    <div class="block">
      <el-pagination layout="prev, pager, next" :total="total"  :current-page.sync="currentPage"
            :page-size="pageSize">
      el-pagination>
    div>
    <div class="newList-list"  v-if="(!isloading) && (arrData.length === 0)"> div>
    <div class="newList-list" v-if="isloading"> ... div>

데이터
data() {
    return {
      arrData: [],
      area: '', //  
      total: 0, //  
      pageNum: 1, //  
      pageSize: 6, //  
      isloading: false,
      currentPage: 1,
    };
  },

watch
 watch: {
    currentPage(oldV, newV) {
      console.log(oldV, newV);
      this.exchangeCurrentPage();
    }
  },

methods
methods: {
    //  
    getData() {
      this.$http.get('//integral' + this.$getHost() + '/enterpriseInfo/queryEnterpriseList.json',
        {
          params: {
            pageSize: this.pageSize,
            pageNum: this.currentPage
          }
        }
      ).then((res) => {
        if (res.data.status === 0) {
          this.isloading = false;
          this.arrData = res.data.datas;
          res.data.datas.forEach((element) => {
            this.area = element.area.split(',');
          });
          this.total = res.data.total; //  
          console.log(this.total);
        }
      });
    },
    exchangeCurrentPage() {
      this.arrData = [];
      this.isloading = true;
      this.getData();
    }
  }

좋은 웹페이지 즐겨찾기