【问题标题】:pull of refresh in nativescript在 nativescript 中拉刷新
【发布时间】:2016-07-20 18:17:47
【问题描述】:

我试图进行拉动以刷新,但我使用的设计无法满足我的主管。如何在nativescript中进行这种拉刷新,现在我在我的项目中使用了这个插件https://www.npmjs.com/package/nativescript-pulltorefresh,我不知道该怎么做,可以给一些建议吗?

【问题讨论】:

    标签: nativescript


    【解决方案1】:

    如果您想在需要时动态加载项目,可以使用 virtual-array 模块。

    Link to documentation examples

    Link to documentation info

    这个想法是您可以创建一个可观察的虚拟数组,它具有初始大小和 loadSize 实例属性。然后在 itemsLoadingEvent 上可以控制新资源的加载。

    var array = new virtualArrayModule.VirtualArray(100);
    array.loadSize = 15;
    array.on(virtualArrayModule.VirtualArray.itemsLoadingEvent, function (args) {
        // Argument (args) is ItemsLoading.
        // args.index is start index of the page where the requested index is located.
        // args.count number of requested items.
        //
        // Note: Virtual array will divide total number of items to pages using "loadSize" property value. When you request an 
        // item at specific index the array will raise "itemsLoading" event with "ItemsLoading" argument index set to the first index of the requested page
        // and count set to number of items in this page. 
        //
        // Important: If you have already loaded items in the requested page the array will raise multiple times "itemsLoading" event to request 
        // all ranges of still not loaded items in this page. 
        var itemsToLoad = new Array();
        for (var i = 0; i < args.count; i++) {
            itemsToLoad.push(i + args.index);
        }
        array.load(args.index, itemsToLoad);
    });

    您可以在此示例应用程序here 中找到有关此功能的更多高级示例

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-08
      • 2014-04-16
      • 2011-09-29
      • 1970-01-01
      相关资源
      最近更新 更多