vue+el-pagination分页 踩坑笔记

设置选中效果和默认效果的相关博客:https://blog.csdn.net/weixin_42418774/article/details/103242571

设置选中效果和默认效果

一、首先说一下原因,我是一页写两个分页器,所以就有一些问题出现了

二、先展示两个分页

 这里是最左边的两个导航分栏
<el-row class="tac">
      <el-col :span="12">
        <el-menu
          default-active="1"
          class="el-menu-vertical-demo"
          text-color="#000"
          active-text-color="#ff784a"
          @select="onClick"    //按钮点击事件
          >
          <el-menu-item index="1" @select="onClick">
            <i class="el-icon-s-custom"></i>
            <span slot="title">哈哈哈</span>
          </el-menu-item>
          <el-menu-item index="2" @select="onClick">
            <i class="el-icon-camera-solid"></i>
            <span slot="title">嘻嘻嘻</span>
          </el-menu-item>
        </el-menu>
      </el-col>
  </el-row>
这里包括了中间的分栏和右边的图片展示区域
<div class="body">
      <div style="width:190px;height:100%">
//名称列表展示
        <el-table
          :data="tableData"
          style="width: 190px;margin-left: 1px;margin-top: 1px;padding-top: 110px;font-size: 16px;height: 100%"
          highlight-current-row
          @row-click="albumClick"  //列表点击事件
          ref="multipleTable"
        >
          <el-table-column
            id="id"
            prop="name"
            label="名称"
            width="190">
          </el-table-column>
        </el-table>
        <!-- 分页器 -->
        <div class="pagBox1">
//两个不同的分页器,就是视觉效果不同
          <!--<el-pagination-->
            <!--@current-change="current_change1"-->
            <!--@size-change="handleSizeChange"-->
            <!--:current-page="1"-->
            <!--layout="total,jumper"-->
            <!--:total="total1">-->
          <!--</el-pagination>-->
          <!--class="page" background-->
//左边列表的分页器
          <el-pagination  layout="prev, pager, next" :total="total1" @current-change='current_change1'  ref="Pagination" :current-page.sync = "currentPage1"></el-pagination>
        </div>
      </div>
//图片展示区
      <div class="img_box">
        <div v-for="img in photoData">
          <!--<image class="img" :src="img.compressUrl" mode="aspectFill"></image>-->
          <img class="img" :src="img.compressUrl" mode="aspectFill"/>
        </div>
      </div>
      <!-- 图片分页器 -->
      <div class="pagBox">
        <el-pagination class="page" background layout="prev, pager, next" :total="total" @current-change='current_change'></el-pagination>
      </div>
    </div>

js事件编写:

 //  左边导航
        onClick(index){
          console.log('index',index)
          if(index ==1){
         //   this.$refs.Pagination.lastEmittedPage = 1
            this.onPhotoAlbumData();
            this.radio="0";
            this.onPhotoData();
          }else{
          //  this.$refs.Pagination.lastEmittedPage = 1
            this.onAlbumdata1();
            this.radio="1";
            this.onPhotoData();
          }
        },
        //名称点击事件
        albumClick(row) {
          this.albumID = row.id;
          this.currentPage=1;
          this.onPhotoData();
          console.log('id--->',this.albumID)
        },
两个分页器点击事件:就是分页器的页码点击事件:1、2、3这些
 //分页器方法
        current_change (currentPage) {
          this.currentPage = currentPage
          this.onPhotoData()   //图片渲染接口
        },
        current_change1 (currentPage1) {
//如果是最左边第一个按钮就执行渲染onPhotoAlbumData方法
            if(this.num == true){
              this.currentPage3 = currentPage1;  //把点击的页码传递给渲染数据接口的参数中
              this.onPhotoAlbumData();
            }else{
//否则就执行onAlbumdata1方法
              this.currentPage2 = currentPage1
              this.onAlbumdata1();
            }
        },

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值