v0.6.1+
To be rendered properly, the refresh/loading Components must appear inside the Scroller Component or the List Component.
example
`<template> <list> <header> <div class="center"> <text style="text-align:center">I am the header</text> </div> </header> <loading onloading="onloading" display="{{loadingDisplay}}" style="width:750;flex-direction: row;justify-content: center;"> <loading-indicator style="height:160;width:160;color:#3192e1"></loading-indicator> </loading> <cell onappear="onappear($event, $index)" ondisappear="ondisappear($event, $index)" class="row" repeat="{{staffs}}" index="{{$index}}"> <div class="item"> <text>{{name}}</text> </div> </cell> </list> </template> <style> .row { width: 750; } .item { justify-content: center; border-bottom-width: 2; border-bottom-color: #c0c0c0; height: 100; padding:20; } .center { border-bottom-width: 2; border-bottom-color: #cccccc; height: 100; padding:20; background-color:#FFFFFF; justify-content: center; } </style> <script> module.exports = { data: { staffs:[], loadingDisplay: 'show', loadingText: 'pull up to load more', refreshText: 'pull down to refresh' }, created:function() { this.refreshDisplay='show' this.staffs=[{name:'inns'},{name:'connon'},{name:'baos'},{name:'anna'},{name:'dolley'},{name:'lucy'},{name:'john'}, {name:'lily'},{name:'locke'},{name:'jack'},{name:'danny'},{name:'rose'},{name:'harris'},{name:'lotus'},{name:'louis'}]; }, methods:{ onappear: function (e, index) { // console.log('+++++', index); // console.log(this.staffs[index].name + ' is appearing...'); }, ondisappear:function (e, index) { // console.log('+++++', index); }, onloading:function(e){ console.log('onloading...'); this.staffs.push({name:'onloading'}) } } } </script>
Any other components, like the text and img components, can be put inside the refresh component. And there is a special component named loading-indicator used only inside the refresh or the loading components.
Other attributes please check out the common attributes.
common styles: check out common styles for components
To be rendered properly, the refresh/loading Components must appear inside the Scroller Component or the List Component.
<template> <scroller onloadmore="onloadmore" loadmoreoffset="1000"> <refresh onrefresh="onrefresh" display="{{refreshDisplay}}"> <text id="refreshText">{{refreshText}}</text> </refresh> <div repeat="{{v in items}}"> <text style="font-size: 40; color: #000000">{{v.item}}</text> </div> <loading onloading="onloading" display="{{loadingDisplay}}"> <text id="loadingText">{{loadingText}}</text> </loading> </scroller> </template> <script> module.exports = { data: { refreshDisplay: 'show', loadingDisplay: 'show', loadingText: 'pull up to load more', refreshText: 'pull down to refresh', items: [] }, created: function () { for (var i = 0; i < 30; i++) { this.items.push({'item': 'test data' + i}); } }, methods: { onrefresh: function () { var vm = this; vm.refreshDisplay = 'show' if (vm.items.length > 50) { vm.refreshText = "no more data!" vm.refreshDisplay = 'hide' return; } var len = vm.items.length; for (var i = len; i < (len + 20); i++) { vm.items.unshift({'item': 'test data ' + i}); } vm.refreshDisplay = 'hide' }, onloading: function () { var vm = this; vm.loadingDisplay = 'show' if (vm.items.length > 30) { vm.loadingText = "no more data!" vm.loadingDisplay = 'hide' return; } var len = vm.items.length; for (var i = len; i < (len + 20); i++) { vm.items.push({'item': 'test data ' + i}); } vm.loadingDisplay = 'hide' }, onloadmore:function(){ console.log("into--[onloadmore]") } } } </script>
Any other components, like the text and img components, can be put inside the refresh component. And there is a special component named loading-indicator used only inside the refresh or the loading components.
Other attributes please check out the common attributes.
common styles: check out common styles for components
example
<template> <list> <header> <div class="center"> <text style="text-align:center">I am the header</text> </div> </header> <refresh onpullingdown='onpullingdown' onrefresh="onrefresh" display="{{refreshDisplay}}" style="width:750;flex-direction: row;justify-content: center;"> <loading-indicator style="height:160;width:160;color:#3192e1"></loading-indicator> </refresh> <cell onappear="onappear" ondisappear="ondisappear" class="row" repeat="{{staffs}}" index="{{$index}}"> <div class="item"> <text>{{name}}</text> </div> </cell> </list> </template> <style> .row { width: 750; } .item { justify-content: center; border-bottom-width: 2; border-bottom-color: #c0c0c0; height: 100; padding:20; } .center { border-bottom-width: 2; border-bottom-color: #cccccc; height: 100; padding:20; background-color:#FFFFFF; justify-content: center; } </style> <script> module.exports = { data: { staffs:[], refreshDisplay: 'show', loadingDisplay: 'show', loadingText: 'pull up to load more', refreshText: 'pull down to refresh' }, created:function() { this.refreshDisplay='show' this.staffs=[{name:'inns'},{name:'connon'},{name:'baos'},{name:'anna'},{name:'dolley'},{name:'lucy'},{name:'john'}, {name:'lily'},{name:'locke'},{name:'jack'},{name:'danny'},{name:'rose'},{name:'harris'},{name:'lotus'},{name:'louis'}]; }, methods:{ onappear: function (e) { var index = e.target.attr.index // console.log(this.staffs[index].name + ' is appearing...'); }, ondisappear:function (e) { }, onrefresh:function(e){ this.refreshDisplay='show'; // this.staffs=[{name:'inns'},{name:'connon'},{name:'baos'},{name:'anna'}]; this.refreshDisplay='hide' // console.log(this.refreshDisplay); }, onpullingdown:function(e){ console.log('onpullingdown triggered.'); console.log('dy:'+e.dy); console.log('headerHeight:'+e.headerHeight); console.log('maxHeight:'+e.maxHeight); } } } </script>