vue+elementUi table模板

<template>
  <div>
    <el-table
      class="el_table_l"
      :data="
        tableData.slice((currentPage - 1) * pageSize, currentPage * pageSize)
      "
      border
      style=""
    >
      <el-table-column :show-overflow="true" label="test" style="width:20%;  ">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <p>test: {{ scope.row.test }}</p>
            <div slot="reference" class="name-wrapper">
              {{ scope.row.test }}
            </div>
          </el-popover>
        </template>
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini">查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      align="right"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      background
      :current-page="currentPage"
      :page-sizes="[1, 5, 10, 20]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.length"
      style="margin-top:10px;"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [{ test: 1 }, { test: 2 }, { test: 3 }],
      currentPage: 1, // 当前页码
      total: 20, // 总条数
      pageSize: 10 // 每页的数据条数
    };
  },
  methods: {
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.currentPage = 1;
      this.pageSize = val;
    },
    //当前页改变时触发 跳转其他页
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.currentPage = val;
    }
  },
  mounted: function() {}
  // getGinfo
};
</script>

<style>
.el_table_l {
  width: 98%;
  margin: 0 auto;
  margin-top: 10px;
  margin-top: 15px;
  box-shadow: 0px 2px 4px 0px rgba(221, 221, 221, 1);
}
</style>

 


版权声明:本文为qq_38921534原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。