• vue element-ui 分页组件封装


    <template>
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-sizes="[10, 20, 30, 40]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total" style="float:right;">
        </el-pagination>
    </template>
    <script type="text/ecmascript-6">
    export default {
        components: {
    
        },
        data() {
            return {
    
            }
        },
        props: {
            pageSize: {
                type: Number,
                default: 10
            },
            total: {
                type: Number,
                default: 1
            }
        },
        watch: {
    
        },
        methods: {
            //每页展示条数
            handleSizeChange(val) {
                //事件传递
                this.$emit('handleSizeChangeSub', val);
            },
            //当前页
            handleCurrentChange(val) {
                //事件传递
                this.$emit('handleCurrentChangeSub', val);
            }
        },
        // 过滤器设计目的就是用于简单的文本转换
        filters: {},
        // 若要实现更复杂的数据变换,你应该使用计算属性
        computed: {
    
        },
        created() {
    
        },
        mounted() {},
        destroyed() {}
    }
    </script>
    <style lang="scss" type="text/css" scoped>
    </style>

    调用

    // 分页
    import pages from 'components/common/pages/pages'

    components: {
      pages
    },

    <pages :total="total" :page-size="pageSize" @handleSizeChangeSub="handleSizeChangeFun" @handleCurrentChangeSub="handleCurrentChangeFun"></pages>

    handleSizeChangeFun(v) {
      this.pageSize = v;
      this._enterpriseList(); //更新列表
    },

    handleCurrentChangeFun(v) { //页面点击
      this.pageNum = v; //当前页
      this._enterpriseList(); //更新列表
    }

  • 相关阅读:
    白菜:小白菜、青菜
    蔬菜:白菜
    蔬菜-白菜:娃娃菜
    玉米:黑玉米
    坚果-花生:彩色花生
    养生-坚果-花生:黑花生
    汉语-词语:气质
    汉语-词语:痛楚
    汉语-词语:酸楚
    汉语-词语:心酸
  • 原文地址:https://www.cnblogs.com/Byme/p/10095144.html
Copyright © 2020-2023  润新知