vue---mint-ui組件loadmore(上拉加載,下拉刷新)

1. 先安裝mint-uicss

2. 在main.js中引入mint-ui的css樣式和組件babel

import "mint-ui/lib/style.css";
import {Loadmore} from 'mint-ui';
Vue.component(Loadmore.name,Loadmore)

 

3. 使用loadmore組件ui

<template>
  <div class="page-loadmore">
      <mt-loadmore :top-method="loadTop"  :bottom-method="loadBottom"  :bottom-all-loaded="allLoaded" ref="loadmore">
        <ul >
          <li v-for="item in list" >{{ item }}</li>
        </ul>
      </mt-loadmore>
  </div>
</template>

 

<script type="text/babel">
  export default {
    data() {
      return {
        list: [],
        allLoaded: false,//數據是否加載完畢
      };
    },
    methods: {
      loadTop() {//上拉加載
        this.$refs.loadmore.onTopLoaded(); },  loadBottom() {//下拉刷新
     var vm = this; this.$refs.loadmore.onBottomLoaded();
     if(!vm.allloaded){
      //調用接口(pageNum+1)
     }else{
      console.log('沒有更多數據了')
     } } },
 }; </script>
相關文章
相關標籤/搜索