【问题标题】:Meteor pagination流星分页
【发布时间】:2018-05-31 21:27:25
【问题描述】:

我正在努力为我的论坛添加分页。你能帮帮我吗?基本上,我希望在我的论坛页面上只能看到 10 个帖子。但它正在返回所有这些。 “加载更多”按钮也没有任何作用(看起来)。

我正在使用这个包:Paginated Subscription

这是我正在使用的代码:

    if (Meteor.isClient) {

Deps.autorun(function() {
var handle = Meteor.subscribeWithPagination('posts',10);

});

Template.postsList.helpers({
    'posts': function(){
        return Posts.find({});
    }
});

Template.postsList.events({
    'click .btn': function(){
        handle.loadNextPage();
    }
})

}

if (Meteor.isServer) {
Meteor.startup(function () {
Meteor.publish("posts", function(limit){
return Posts.find({}, {limit: limit});
});

});

}

【问题讨论】:

    标签: meteor pagination


    【解决方案1】:

    我不认为var handle = Meteor.subscribeWithPagination('posts',10); 需要在Deps 块中,除非您将一些反应参数传递给handle

    在 Github 上查看 Issue

    【讨论】:

      【解决方案2】:

      您可以使用Kurounin基于订阅的分页。它适用于我。在大气js中,还有另一个反应分页,您可以在Krounin存储库中查看它

      【讨论】:

        【解决方案3】:

        我已经回答了一个问题的这种分页。请参考可以帮助您的确切代码。

        Meteor Pagination Issue

        【讨论】:

          【解决方案4】:

          在您的出版物中,您必须使用 sort(如文档所述)

          //这里使用排序是继续使用Oplog观察的必要条件 司机!

          //https://github.com/meteor/meteor/wiki/Oplog-Observe-Driver

          Meteor.publish("posts", function(limit){
            return Posts.find({}, {
              limit: limit,
              sort: {
                createdAt: -1
              }
            });
          });
          

          【讨论】:

            猜你喜欢
            • 2017-05-25
            • 1970-01-01
            • 2018-01-09
            • 1970-01-01
            • 1970-01-01
            • 2012-06-26
            • 2014-03-04
            • 2015-11-03
            • 2014-07-03
            相关资源
            最近更新 更多