乱码乱a∨中文字幕,在线免费激情视频,亚洲欧美久久夜夜潮,国产在线网址

  1. <sub id="hjl7n"></sub>

    1. <sub id="hjl7n"></sub>

      <legend id="hjl7n"></legend>

      當前位置:首頁 >  站長 >  編程技術 >  正文

      vue+iview分頁組件的封裝

       2020-11-19 15:18  來源: 腳本之家   我來投稿 撤稿糾錯

        阿里云優(yōu)惠券 先領券再下單

      這篇文章主要為大家詳細介紹了vue+iview分頁組件的封裝,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

      vue+iview的分頁組件封裝

      1.在components中創(chuàng)建pagination文件夾,接著創(chuàng)建src,index.js,index.less文件

      2.index.less文件

      //需要修改的樣式
      .ivu-page-options {
       margin-left: 10px;

       .ivu-page-options-sizer {
        margin-right: 0;
       }
       }

      3.index.js文件

      import "./index.less";
      import component from "./src/main";

      /* istanbul ignore next */
      component.install = function (Vue) {
       Vue.component(component.name, component);
      };

      export default component;

      4.src文件夾中的main.vue

      <template>
       <!-- 分頁組件 -->
       <Page
       class="saas-pagination"
       ref="page"
       :loading="loading"
       :disabled="disabled"
       :total="total"
       :show-sizer="sizer"
       :show-elevator="elevator"
       :current="params.page"
       :page-size="params.rows"
       :page-size-opts="sizeOpts"
       @on-change="currentChange"
       @on-page-size-change="pageChange"/>
      </template>

      <script>
      export default {
       props: {
       loading: {
        type: Boolean,
        default: false
       },
       total: {
        // 數據總數
        type: [String, Number],
        default: 0
       },
       page: {
        // 當前分頁
        type: [String, Number],
        default: 1
       },
       rows: {
        // 每頁顯示多少條
        type: [String, Number],
        default: 10
       },
       disabled: {
        type: Boolean,
        default: false
       },
       sizer: {
        // 是否顯示下拉組件
        type: Boolean,
        default: false
       },
       elevator: {
        // 是否顯示跳轉輸入框
        type: Boolean,
        default: false
       }
       },
       watch: {
       page (to) {
        this.params.page = to;
       },

       rows (to) {
        this.params.rows = to;
       }
       },
       data () {
       return {
        sizeOpts: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
        params: {
        page: 1,
        rows: 10
        }
       }
       },
       methods: {
       // 分頁改變
       currentChange (current) {
        this.params.page = current;
        this.onChange();
       },
       // 每頁顯示條數改變
       pageChange (rows) {
        this.params.page = 1;
        this.params.rows = rows;
        this.onChange();
       },

       onChange () {
        this.$emit("on-change", JSON.parse(JSON.stringify(this.params)));
       },

       reset () {
        this.params = {
        page: 1,
        rows: 10
        }
        this.onChange();
        // 當前頁碼還原
        // this.$refs.page.currentPage = 1;
       }
       }
      }
      </script>

      5.在components中創(chuàng)建index.js,用于全局引入

      import GlobalPage from "@/components/pagination/index.js";
      export default (Vue) => {
       Vue.component("GlobalPage ", GlobalPage );
      }

      6然后在全局的main.js引入,可全局使用

      import components from "@/components/index.js";
      Vue.use(components)

      7.組件的使用

      <template>
       <div>
        <global-page
        ref="pagination"
        :sizer="true"
        :page="formData.page"
        :rows="formData.rows"
        :total="total"
        @on-change="pageChange">
        </global-page>
       </div>
      </template>
      <script>
      export default {
       data(){
       return {
        total: 0, // 數據總數
        queryForm:{},
        formData: {
         page: 1,
         rows: 10,
        }
        }
       },
       methods: {
        // 分頁切換
       pageChange (params) {
        this.queryForm.page = params.page
        this.queryForm.rows = params.rows
        //查詢數據的方法
        this.search(this.queryForm)
       },
       }
      }

      </script>

      關于vue.js組件的教程,請大家點擊專題vue.js組件學習教程進行學習。

      以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

      來源:腳本之家

      鏈接:https://www.jb51.net/article/199919.htm

      申請創(chuàng)業(yè)報道,分享創(chuàng)業(yè)好點子。點擊此處,共同探討創(chuàng)業(yè)新機遇!

      相關標簽
      vue.js

      相關文章

      • Vue 3自定義指令開發(fā)的相關總結

        這篇文章主要介紹了Vue3自定義指令開發(fā)的相關總結,幫助大家更好的理解和使用vue框架,感興趣的朋友可以了解下

        標簽:
        vue.js
      • vue集成一個支持圖片縮放拖拽的富文本編輯器

        文章主要介紹了vue集成一個支持圖片縮放拖拽的富文本編輯器,幫助大家更好的理解和使用vue框架,感興趣的朋友可以了解下。

        標簽:
        vue.js
      • vue自定義組件實現雙向綁定

        這篇文章主要為大家詳細介紹了vue自定義組件實現雙向綁定,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

        標簽:
        vue.js
      • Vue實現隨機驗證碼功能

        這篇文章主要為大家詳細介紹了Vue實現隨機驗證碼功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

        標簽:
        vue.js
      • vue實現樹狀表格效果

        這篇文章主要為大家詳細介紹了vue實現樹狀表格效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

        標簽:
        vue.js

      熱門排行

      信息推薦