分页的实现(Vue+Element)+输入框关键字筛选

1.这里用的是Element 自带的分页组件
<template>
<div class="sales-table">
<div class="order-list-header">订单列表</div>
<div class="back-box">
<div class="search-box"><input type="text" name="" id="" class="order-search-input" placeholder="关键词" v-model='search'></div>
</div>
<div class="table-box">
<div class="table-list" v-for="(cash, index) in orderList.slice((currentPage-1)*pagesize,currentPage*pagesize)" :key="cash.id">
<table id="tableSort" style="table-layout:fixed;">
<thead class="table-header">
<tr>
<th class="left-radius">序号</th>
<th>创建时间</th>
<th>订单ID</th>
<th>所属用户姓名</th>
<th>所属用户ID</th>
<th>所属用户手机</th>
<th>所属用户层级</th>
<th>订单金额</th>
<th>订单状态</th>
<th>审核状态</th>
<th>收件人</th>
<th>联系电话</th>
<th>收货地址</th>
<th>订单备注</th>
<th class="right-radius">操作</th>
</tr>
</thead>
<tbody class="table-lists">
<tr class="first-tr">
<td class="sequence">{{ index+1>9?index+1:"0"+(index+1) }}</td>
<td class="sequence">{{cash.createTime}}</td>
<td class="sequence">{{cash.orderId}}</td>
<td class="sequence">{{cash.cilentName}}</td>
<td class="sequence">{{cash.cilentId}}</td>
<td class="sequence">{{cash.cilentPhone}}</td>
<td class="sequence">{{cash.cilentGrade}}</td>
<td class="sequence money">¥{{cash.orderPrice}}</td>
<td class="sequence">{{cash.orderState}}</td>
<td class="sequence">{{cash.auditState}}</td>
<td class="sequence">{{cash.receiver}}</td>
<td class="sequence">{{cash.phone}}</td>
<td class="sequence">{{cash.address}}</td>
<td class="sequence">{{cash.orderRemark}}</td>
<td class="sequence"><a class="view-order">查看</a><a class="edit-order">编辑</a><a class="delete-order">删除</a></td>
</tr>
</tbody>
</table>
</div>
</div>
<-- 分页 -->
<div class="page">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[5, 10, 20, 40]"
:page-size="pagesize"
layout="total, sizes, prev, pager, next, jumper"
:total="Cashdata.length">
</el-pagination>
</div>
</div>
</template>

2.文中标红的字不再是循环数组,名字随意取,在后面搜索关键字部分也标红了。数据多分页效果会更加明显。

<script>
export default {
data() {
  return {
    currentPage:1, //初始页
    pagesize:10,//每页的数据// 搜索关键词
    search:"",
    Cashdata: [{
      createTime:"2019/1/21/ 14:30:30",
      orderId: "1555555454",
      cilentName:"网三",
      cilentId:"21313216544",
      cilentPhone:"13976605432",
      cilentGrade:"1",
      orderPrice:"454664",
      orderState:"已提交",
      auditState: "系统已确认",
      receiver: "和大宝",
      phone:"16565644444",
      address:"广东省深圳市*************************",
      orderRemark:"少放醋,多方唐撒旦啊阿萨大萨达"
    },
    {
      createTime:"2019/1/21/ 14:30:30",
      orderId: "1555555454",
      cilentName:"网三",
      cilentId:"21313216544",
      cilentPhone:"15576605432",
      cilentGrade:"1",
      orderPrice:"454664",
      orderState:"已提交",
      auditState: "系统已确认",
      receiver: "和大宝",
      phone:"16565644444",
      address:"广东省深圳市*************************",
      orderRemark:"少放醋,多方唐撒旦啊阿萨大萨达"
      },
     ]};
    },
    methods: {
      // 初始页currentPage、初始每页数据数pagesize和数据data
      handleSizeChange: function (size) {
      this.pagesize = size;
      console.log(this.pagesize) //每页下拉显示数据
     },
      handleCurrentChange: function(currentPage){
        this.currentPage = currentPage;
        document.documentElement.scrollTop = 0;//点击翻页的时候回到顶部
        console.log(this.currentPage) //点击第几页
      },
     },
  // 订单列表搜索关键字
   computed: {
    orderList: function() {
    var _search = this.search;
    if (_search) {
      return this.Cashdata.filter(function(product) {
      return Object.keys(product).some(function(key) {
      return String(product[key]).toLowerCase().indexOf(_search) > -1
    })
  })
  }
    return this.Cashdata;
    }
  }
};
</script>

3.分页的CSS只是自己修改的部分,如有需要,请自行脑补。对了,补充一句,修改Eleement样式时,先在样式前加   /deep/.最外层类名{......}。


<style lang="scss" scoped>
/deep/.el-pagination{
margin-bottom: 30px;
margin-top: 30px;
float: right;
font-size: 20px;
color: #333333;
margin-right: 55px;
font-weight: normal; .el-select .el-input{
width: 126px;
height: 36px;
}
.el-select .el-input .el-input__inner{
height: 100%;
font-size: 20px;
color: #333333;
}
.el-pagination__editor.el-input .el-input__inner{
height: 36px;
}
.btn-prev,.btn-next{
height: 36px;
}
.btn-prev{
border-radius: 5px 0 0 5px;
}
.btn-next{
border-radius: 0 5px 5px 0;
}
.el-pager li{
line-height: 36px;
height: 36px;
font-size: 20px;
}
.el-pagination__total{
color: #333333;
}
button,span:not([class*=suffix]){
height: 36px;
line-height: 36px;
font-size: 20px;
color: #333333;
}
.el-pagination__editor.el-input{
font-size: 20px;
}
}
</style>

4.如有问题,欢迎指教。

附上效果图一份:

Vue 实现分页+输入框关键字筛选的更多相关文章

  1. 基于Vue封装分页组件

    使用Vue做双向绑定的时候,可能经常会用到分页功能 接下来我们来封装一个分页组件 先定义样式文件 pagination.css ul, li { margin: 0px; padding: 0px;} ...

  2. JS(vue iview)分页解决方案

    JS(vue iview)分页解决方案 一.解决思路 使用分页组件 使用组件API使组件自动生成页面数量 调用组件on-change事件的返回值page 将交互获得的数组存在一个数组list中 通过p ...

  3. 【前端】vue.js实现输入框绑定

    vue.js实现输入框绑定 实现效果如下: 实现代码及注释 <!DOCTYPE html> <html> <head> <title>vue.js数据动 ...

  4. 基于vue的分页插件

    相信大家用过很多jquery的分页插件,那这次就用一用基于vue的分页插件. 这里的环境用的是springboot 首先要引入pagehelper的jar文件,版本是1.2.3,配置文件也需要配置一下 ...

  5. VUE实现限制输入框最多输入15个中文,或者30个英文

    vue项目,输入框限制输入15个中文,或者30个英文 <input type="text" v-model="groupName" class=" ...

  6. vue的品牌添加与筛选的功能集合

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. vue+ springboot 分页(两种方式:sql分页 & PageHelper 分页)

    方法一:sql分页 思路:使用数据库进行分页   前端使用element-ui的分页组件,往后台传第几页的起始行offest 以及每页多少行pageSize,后台根据起始行数和每页的行数可以算出该页的 ...

  8. 使用EditText+ListView并结合TextWatcher实现输入关键字筛选数据

    想必大家应该遇到过这样的情况,当点击Spinner控件后弹出的列表内容超多,一个一个滑动着去寻找所要的项很麻烦,尤其是当自己知道想要选择的内容,这时候如果我们只需要输入某些关键字,就可以讲上百条数据筛 ...

  9. vue中input输入框的模糊查询实现

    最近在使用vue写webapp在,一些感觉比较有意思的分享一下. 1:input输入框: <input class="s-search-text" placeholder=& ...

随机推荐

  1. laravel 自定义全局函数

    在 app 目录下创建一个 Helpers 目录,在此目录下创建文件.这些文件就是全局函数文件.如叫:function.php 加载此文件: 1 . 在 bootstrap/autoload.php ...

  2. while循环合理运用-判断成绩脚本

    在平时的工作生活中,难免不了去写一些交互性质的脚本,然而呢往往有些用户偏偏会输入不合规范的输入,为了避免就此退出脚本重新执行,这时候就可以用while去写一个死循环去针对用户的输出啊.哈哈~他输不对, ...

  3. awk 基础的用法

    基本的awk执行过程#passwd文件的第二行的第一列和第二列[root@oldboyedu01-nb ~]# awk -F ":" 'NR==2{print $1,$2}' /e ...

  4. HDU 4937 Lucky Number 搜索

    题意: 给你一个数,求在多少种不同的进制下这个数每一位都是3.4.5.6中的一个. 思路: 搜索.枚举这个数在任意进制下的表示,判断是否合法.当数字只有3.4.5.6时,必定有无穷种. 因为数字太大, ...

  5. CF 414B Mashmokh and ACM 动态规划

    题意: 给你两个数n和k.求满足以下条件的数列有多少个. 这个数列的长度是k: b[1], b[2], ……, b[k]. 并且 b[1] <= b[2] <= …… <= b[k] ...

  6. 洛谷——P3374 【模板】树状数组 1

    https://www.luogu.org/problem/show?pid=3374 题目描述 如题,已知一个数列,你需要进行下面两种操作: 1.将某一个数加上x 2.求出某区间每一个数的和 输入输 ...

  7. Import .bak file to a database in SQL server

    https://stackoverflow.com/questions/1535914/import-bak-file-to-a-database-in-sql-server On SQL Serve ...

  8. JAVA 解析复杂的json字符串

    转自:https://blog.csdn.net/lovelovelovelovelo/article/details/73614473String parameter = { success : 0 ...

  9. javascript 提交弹窗

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. flowable一个简单的例子

    holiday-request.bpmn20.xml: <?xml version="1.0" encoding="UTF-8"?> <def ...