ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# mui+vue2.0 实现上拉刷新下拉加载 > 来源: http://banyingli.cn/?p=92 #### HTML ```html <!--下拉刷新容器--> <div id="pullrefresh" class="mui-content mui-scroll-wrapper"> <div class="mui-scroll"> <!--数据列表--> <ul class="mui-table-view mui-table-view-chevron"> <li class="mui-table-view-cell" v-for="(item, index) in items"> <a href="" class="mui-navigate-right">{{item.title}}</a> </li> </ul> </div> </div> ``` #### JavaScript ```javascript var demo = new Vue({ el: '#pullrefresh', data: { count : 0, items : [{title: 'item1'}] }, methods: { pulldownRefresh : function(){ setTimeout(function() { var addedArray = []; for (var i = demo.items.length + 1, len = i + 3; i < len; i++) { addedArray.push({title: 'item'+i}); } demo.items = addedArray.concat(demo.items); mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed }, 1000); }, pullupRefresh: function(){ setTimeout(function() { var addedArray = []; for (var i = demo.items.length + 1, len = i + 4; i < len; i++) { addedArray.push({title: 'item'+i}); } demo.items = demo.items.concat(addedArray); mui('#pullrefresh').pullRefresh().endPullupToRefresh(); }, 1000); } } }); mui.init({ pullRefresh: { container: '#pullrefresh', down: { contentrefresh: '正在下拉...', callback: demo.pulldownRefresh }, up: { contentrefresh: '正在加载...', callback: demo.pullupRefresh } } }); ```