美文网首页
mint-ui 实现上拉加载

mint-ui 实现上拉加载

作者: _Struggle_ | 来源:发表于2018-09-18 17:33 被阅读0次
  1.先安装mint-ui
      npm install mint-ui -S
   2.引入mint-ui
      import 'mint-ui/lib/style.css'
      import { Loadmore } from 'mint-ui';
      Vue.component(Loadmore.name, Loadmore);

    3.下面是代码:(拿着就可以直接用) 下拉刷新直接看官网加参数就OK

        <template>
            <div id="content">
                <mt-loadmore :bottom-method="loadBottom" :bottom-all-loaded="allLoaded" :auto-fill="false" ref="loadmore">
                         <div class="item" v-for="(item,index) in list" :key="index">
                      <div class="name">{{item.title}} + {{index}}</div>
                   </div>
                </mt-loadmore>
          </div>
        </template>

<script>
    import { Loadmore } from 'mint-ui';
    import Vue from 'vue'
    Vue.component(Loadmore.name, Loadmore);

    var p = 1;
     export default {
        data(){
            return{
                 list:[],
                allLoaded:false,
            }
        },
        methods:{
            loadBottom: function(){
                this.$refs.loadmore.onBottomLoaded();
                this.getList();
            },
            getList: function(){
                this.$http.get("自己的接口信息?st=0&et=0&page="+p+"&offset=条数").then(res=>{
                    this.list = this.list.concat(res.data.data)
                    console.log(this.list)
                    
                })
                
                p += 1 
            }
        },
        mounted: function(){
            this.getList();
        }
    }
</script>
<style scoped>
        #content{
            overflow: scroll;
        }
        .item{

        }
        .item .name{
            height: 50px;
            background-color: green;
            margin-bottom: 10px;
        }
    </style>
        

相关文章

网友评论

      本文标题:mint-ui 实现上拉加载

      本文链接:https://www.haomeiwen.com/subject/aqxmnftx.html