vue 分页组件_bootstrap 分页

vue 分页组件_bootstrap 分页1、page.vue组件<template><divclass=”greenpage”><!–:layout=”layout”–><el-pagination:background=”background”:current-page.sync=”currentPage”:page-size.sync=”pageSize”:page-sizes=”pageSizes”

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

1、page.vue组件

<template>
  <div class="greenpage">
    <!-- :layout="layout" -->
     <el-pagination
      :background="background"
      :current-page.sync="currentPage"
      :page-size.sync="pageSize"
      :page-sizes="pageSizes"
      :total="total"
      v-bind="$attrs"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    /> 
  </div>
</template>

<script>
import { scrollTo } from '@/utils/scroll-to'

export default {
  name: 'Pagination',
  props: {
    total: {
      required: true,
      type: Number
    },
    page: {
      type: Number,
      default: 1
    },
    limit: {
      type: Number,
      default: 20
    },
    pageSizes: {
      type: Array,
      default() {
        return [10, 20, 30, 50]
      }
    },
    layout: {
      type: String,
      default: 'total, sizes, prev, pager, next, jumper'
    },
    background: {
      type: Boolean,
      default: true
    },
    autoScroll: {
      type: Boolean,
      default: true
    },
    hidden: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    currentPage: {
      get() {
        return this.page
      },
      set(val) {
        this.$emit('update:page', val)
      }
    },
    pageSize: {
      get() {
        return this.limit
      },
      set(val) {
        this.$emit('update:limit', val)
      }
    }
  },
  methods: {
    handleSizeChange(val) {
      this.$emit('pagination', { page: this.currentPage, limit: val })
      if (this.autoScroll) {
        scrollTo(0, 800)
      }
    },
    handleCurrentChange(val) {
      this.$emit('pagination', { page: val, limit: this.pageSize })
      if (this.autoScroll) {
        scrollTo(0, 800)
      }
    }
  }
}
</script>

<style scoped>
.greenpage /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
    background-color: #007f69;
    color: #FFFFFF;
}
</style>

2、scroll-to.js

Math.easeInOutQuad = function(t, b, c, d) {
  t /= d / 2
  if (t < 1) {
    return c / 2 * t * t + b
  }
  t--
  return -c / 2 * (t * (t - 2) - 1) + b
}

// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts
var requestAnimFrame = (function() {
  return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) }
})()

/**
 * Because it's so fucking difficult to detect the scrolling element, just move them all
 * @param {number} amount
 */
function move(amount) {
  document.documentElement.scrollTop = amount
  document.body.parentNode.scrollTop = amount
  document.body.scrollTop = amount
}

function position() {
  return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop
}

/**
 * @param {number} to
 * @param {number} duration
 * @param {Function} callback
 */
export function scrollTo(to, duration, callback) {
  const start = position()
  const change = to - start
  const increment = 20
  let currentTime = 0
  duration = (typeof (duration) === 'undefined') ? 500 : duration
  var animateScroll = function() {
    // increment the time
    currentTime += increment
    // find the value with the quadratic in-out easing function
    var val = Math.easeInOutQuad(currentTime, start, change, duration)
    // move the document.body
    move(val)
    // do the animation unless its over
    if (currentTime < duration) {
      requestAnimFrame(animateScroll)
    } else {
      if (callback && typeof (callback) === 'function') {
        // the animation is done so lets callback
        callback()
      }
    }
  }
  animateScroll()
}

3、使用组件页面

 <Page
          v-show="total > 0"
          :total="total"
          :page.sync="pageList.pageNum"
          :limit.sync="pageList.pageSize"
          :page-sizes="pageList.pageSizes"
          @pagination="getList"
        />
        export default {
        data(){
        return {
        // 总条数
      total: 0,
      // 查询参数
      pageList: {
        pageNum: 1,
        pageSize: 10,
        pageSizes: [10, 20, 40, 60],
      },
        }
        }        }
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/189034.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • java static 变量存在哪_Java中的静态方法和静态变量存储在哪里?

    java static 变量存在哪_Java中的静态方法和静态变量存储在哪里?小编典典静态方法(实际上是所有方法)以及静态变量都存储在PermGen堆的部分中,因为它们是反射数据(与类相关的数据,而不与实例相关的数据)的一部分。更新说明:请注意,只有变量及其技术值(原始或引用)存储在PermGen空间中。如果你的静态变量是对对象的引用,则对象本身存储在堆的常规部分(青年/旧世代或幸存者空间)中。这些对象(除非它们是类之类的内部对象)不会存储在PermGen空间中。例:sta…

    2022年5月4日
    207
  • MySQL数据库:通用查询日志和慢查询日志分析

    MySQL数据库:通用查询日志和慢查询日志分析

    2021年4月9日
    124
  • Flowable API

    Flowable APIFlowableAPI 流程引擎API与服务引擎API是与Flowable交互的最常用手段。总入口点是ProcessEngine。可以使用多种方式创建。使用ProcessEngine,可以获得各种提供工作流/BPMN方法的服务。它是线程安全的,可以在服务器中保存并共用一个引用。  ProcessEngineprocessEngine=ProcessEngine…

    2022年5月11日
    268
  • python怎么定义数组长度_python中如何定义数组

    python怎么定义数组长度_python中如何定义数组广告关闭腾讯云11.11云上盛惠,精选热门产品助力上云,云服务器首年88元起,买的越多返的越多,最高返5000元!python返回数组(list)长度的方法array=printlen(array)…如何查找二维数组中有多少行和列?例如,input=(,,])`应显示为3行和2列…所以我在python中实现了一个块交换算法。我遵循的算法是这样的:初始化a=arr…

    2022年8月13日
    23
  • 关于lvm扩容的方式「建议收藏」

    关于lvm扩容的方式「建议收藏」服务器磁盘扩容在项目上很常见,这里总结下常见的几种lvm扩容的方式供大家参考。

    2022年6月20日
    74
  • vue的form表单提交_axios提交表单

    vue的form表单提交_axios提交表单利用v-model能比较便捷地上传用户信息的数据,不用一个个参数地拼接。直接在data根据要传的字段定义一个对象,再利用双向绑定得到值。下面写了传json格式跟formData格式的两种情况,根据实际参考<template><divclass=”from_box”><formaction=””><inputty……

    2022年10月7日
    6

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号