带有ListView和nativescript vue的无限滚动
我想知道是否可以使用nativescript vue在ListView上实现无限滚动 目前,我只看到@itemTap事件,但没有看到与ListView和nativescript vue一起用于实现无限滚动的其他事件带有ListView和nativescript vue的无限滚动,listview,nativescript,nativescript-vue,Listview,Nativescript,Nativescript Vue,我想知道是否可以使用nativescript vue在ListView上实现无限滚动 目前,我只看到@itemTap事件,但没有看到与ListView和nativescript vue一起用于实现无限滚动的其他事件 <ListView class="list-view" v-for="(post, indexPost) in posts" @itemTap="loadMore"> <v-template>
<ListView class="list-view" v-for="(post, indexPost) in posts" @itemTap="loadMore">
<v-template>
<StackLayout class="list-element" orientation="vertical">
<post :post="post" />
</StackLayout>
</v-template>
</ListView>
我想听听ListView上的滚动条
对于vue native,我使用以下滚动视图实现它:
<scroll-view :on-scroll="(event) => {loadMore(event)}" :scroll-event-throttle="400">
<post v-for="(post, indexPost) in posts" :post="post" />
</scroll-view>
...
loadMore: function (event) {
let paddingToBottom = 0;
paddingToBottom += event.nativeEvent.layoutMeasurement.height;
if (event.nativeEvent.contentOffset.y >= event.nativeEvent.contentSize.height - paddingToBottom) {
this.getData()
}
},
...
loadMore:函数(事件){
让paddingToBottom=0;
paddingToBottom+=event.nativeEvent.layoutMeasurement.height;
if(event.nativeEvent.contentOffset.y>=event.nativeEvent.contentSize.height-paddingToBottom){
这个文件名为getData()
}
},
我想用nativescript vue实现同样的功能…您可以使用nativescript的RadListView而不是常规的ListView。 这里是到和的链接
RadListView
有一个名为loadOnDemand
的属性,让您添加一种方法来触发getData
并更新列表视图
有关loadOnDemand
功能的一些附加信息
代码应与此类似:
publicAddMoreItemsFromSource(chunkSize:number,listView:RadListView){
让newItems=this.\u sourceDataItems.splice(0,chunkSize);
this.dataItems.push(newItems);
如果(列表视图){
//调用优化函数按需加载完成。
//(使用0,因为ObservableArray已
//已通知已插入的项目)
listView.notifyAppendItemsOnDemandFinished(0,this.\u sourceDataItems.length==0);
}
}
公共onLoadMoreItemsRequested(参数:LoadOnDemandListViewEventData){
const that=new WeakRef(this);
const listView:RadListView=args.object;
如果(此._sourceDataItems.length>0){
setTimeout(函数(){
that.get().addMoreItemsFromSource(20,listView);
}, 0);
args.returnValue=true;
}否则{
args.returnValue=false;
listView.notifyAppendItemsOnDemandFinished(0,true);
}
}