element分页功能再vue中使用(绝对)

        其中我们使用没办法适用到视图中,这时我们其实需要使用slice来截取数组

    <table>
      <tr>
        <th @click="idsort">ID <i class="el-icon-sort"></i></th>
        <th>商品名</th>
        <th @click="pricesort">价格<i class="el-icon-sort"></i></th>
      </tr>
    //这个slice后面跟的数据是通过数组的截取
    //当前第几页(currentPage)-1 *每页显示几条(pagesize),currentPage*pagesize
    //把相应的数带入可计算出
    //-1是为了让他们永远有一个差值,意思就是取一页的数据。
      <tr  v-for="(item,index) in searchold.slice((currentPage-1)*pagesize,currentPage*pagesize)" :key="index">      
        <td>{{item.id}}</td>
        <td>{{item.title}}</td>
        <td>{{item.price}}</td>
      </tr>
    </table>
    <div class="block">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="currentPage"
      :page-sizes="[1, 2, 5, 10]"
      :page-size="pagesize"
      layout="sizes, prev, pager, next"
      :total="goodsData.length">
    </el-pagination>
      </div>
<script>
export default {
props:[],
data(){
return{
  goodsData:[
  ],
  title:'',
  searchold:[],
  allpage:'',
  currentPage:1,
  pagesize:1,
}
methods: {
//方法
handleSizeChange(e){
  this.pagesize=e
//这是从子组件中传过来的事件e是一页显示多少条数据
},
handleCurrentChange(e){
  this.currentPage=e
//这是从子组件中传过来的事件e是当前是第几页
}
},
components:{
//注册子组件
},

<el-pagination

      @size-change="handleSizeChange" **选择的第几页

      @current-change="handleCurrentChange" **选择的一页多少条

      :current-page.sync="currentPage" 当前页码

      :page-sizes="[1, 2, 5, 10]"   条数选择项

      :page-size="pagesize"   每页多少条

      layout="sizes, prev, pager, next"

      :total="totols"  总条数>

    </el-pagination>

  • 9
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

长风戏子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值