<ul class="list" style="overflow:auto" v-infinite-scroll = "load"> <li class="li" v-for="item in count">{{item}}</li> </ul> <script> export default { data(){ return{ loading:false, count: 10 } }, methods:{ load(){ this.loading= true this.count += 2 } } } </script> <style> .list{ list-style:none; text-align:center; height:200px; } .list .li{ height:30px; line-height:30px; background: #e8f3fe; margin: 5px 0; } </style>
<ul class="list" style="overflow:auto" v-infinite-scroll = "load" infinite-scroll-disabled="disabled" infinite-scroll-distance="10" infinite-scroll-delay="200"> <li class="li" v-for="item in count">{{item}}</li> <p class="li" v-if="loading">加载中...</p> <p class="li" v-if='noMore'>我也是有底线的</p> </ul> <script> export default { data(){ return{ loading:false, count: 10 } }, computed:{ disabled(){ return this.loading||this.noMore }, noMore(){ return this.count>=20 } }, methods:{ load(){ this.loading= true setTimeout(()=>{ this.count += 2 this.loading=false },2000) } } } </script> <style> .list{ list-style:none; text-align:center; height:200px; } .list .li{ height:30px; line-height:30px; background: #e8f3fe; margin: 5px 0; } </style>
← Tree 树形控件 Pagination 分页器 →