写列表

data里面定义

 	  tableloading: true,//加载
 	  pageDis: true, //分页显示
      loading: false, // 页面加载……
      tableShow: true, //列表信息显隐
      esultShow: false, // 数据搜索结果为空的样式显示
      ResultShow: false, // 控制搜索结果的显示
      EmptysShow: false, //空数据样式
      currentPage: 1, //当前第几页
      total: 0, //一共多少条数据
      perPage: 10, //每页多少条数据
      tableData: [], //列表数据

请求接口

    if (response.data.code == 1) {
            var conData = response.data.data; //获取整体数据
            this.tableData = conData.data; //获取列表数据
            this.total = conData.total; //总条数
            this.currentPage = conData.current_page; //当前页
            this.pageDis = this.total > 10 ? false : true; //判断分页的显隐
            //条数判断数据为空,10条
            if (this.total == 0 && !this.input) {
              this.tableShow = false;
              this.ResultShow = false;
              this.esultShow = false;
              this.EmptysShow = true;
            } else if (this.total == 0 && this.input) {
              this.tableShow = false;
              this.ResultShow = true;
              this.esultShow = true;
              this.EmptysShow = false;
            } else if (this.total != 0 && !this.input) {
              this.tableShow = true;
              this.ResultShow = false;
              this.esultShow = false;
              this.EmptysShow = false;
            } else if (this.total != 0 && this.input) {
              this.tableShow = true;
              this.ResultShow = true;
              this.esultShow = false;
              this.EmptysShow = false;
            }
            this.tableloading = false;
          } else {
            this.$message.error(res.data.msg);
          }

分页

  // 切换总条数
    handleSizeChange(val) {
      this.currentPage = 1;
      this.perPage = val;
      this.getData();
    },
    // 切换分页
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getData();
    }
      //搜索方法
    search() {
      if (this.input.length > 0) {
        this.getData();
      }
    },
    //搜索点击清空刷新页面
    qingkong() {
      this.currentPage = 1;
      this.ResultShow = false;
      this.getData();
    },

组件

 <!-- 搜索结果展示 -->
      <div class="searchResult" v-show="ResultShow">
        根据“
        <span class="blue">{{input}}</span>”共找到
        <span class="red">{{total}}</span>条信息
      </div>
 <!-- 搜索结果展示 -->

列表

v-show="tableShow"

搜索为空和空页面

<Result v-show="esultShow"></Result>
<Emptys v-show="EmptysShow"></Emptys>

分页

 <!-- 分页 -->
      <div class="page">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[10, 30, 50, 100]"
          :page-size="perPage"
          :hidden="pageDis"
          layout="total, sizes, ->,prev, pager, next, jumper"
          :total="total"
          popper-class="page-select"
        ></el-pagination>
      </div>
      <!-- 分页 -->
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值