mint-ui 实现上拉加载

  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>
        
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容