鍍金池/ 問答/HTML/ 關于element-ui分頁組件的問題

關于element-ui分頁組件的問題

寫了一個很簡單的分頁組件,但是放到頁面頁面上不能用,點擊頁面標簽頁面上一點效果都沒有,也沒有報錯,值都傳過去了,也可以打印出來,大家?guī)兔纯茨睦锍鲥e了

<template>
  <div class="el-table-self">
      <el-pagination
              :current-page="currentPage"
              :page-size="pagesize"
              layout="prev, pager, next"
              :total="totalCount">
      </el-pagination>
  </div>
</template>

<script>
  export default{
    data(){
      return {
//        pagesizes:this.pagesize,
//        currentPage:this.currentPage
      }
    },
  created(){
    console.log(this.pagesize);
    console.log(this.totalCount);
    console.log(this.currentPage);
  },
    props:{
      totalCount:Number,  //表格數(shù)據(jù)總數(shù)
      pagesize:Number,    //決定每頁顯示的條數(shù)
      currentPage:Number,
    },
    methods:{
    }
  }

</script>
<style></style>

父組件

      <tree-grid
                     :columns="columns"
                     :dataSource="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
                
      </tree-grid>

    <paging  :totalCount="totalCount"
      :pagesize="pagesize"
      :currentPage="currentPage"></paging>
      
      data(){
            return {
                pagesize:2,
                currentPage:2,
                totalCount:'',
            }
        }
回答
編輯回答
涼心人

你把組件里 el-paginationcurrent-change 事件 $emit 出來 ,然后由父組件改 currentPage 的值

2017年3月6日 11:14
編輯回答
陌如玉

那啥,看看api,琢磨下就好了,10分鐘的事。

2018年6月26日 16:34
編輯回答
大濕胸

需要引入組件
import Paging from '組件地址'
export default {

components: {
    Paging
  }

}

2017年4月29日 22:48