Pagination 无法使Meteor分页工作
我正在尝试向meteor应用程序添加分页支持,但是一旦我在模板中添加{{{pagination}}}标记,我的模板就会显示一个空白页面。日志中没有错误 我的客户端js(路由信息)如下所示Pagination 无法使Meteor分页工作,pagination,meteor,Pagination,Meteor,我正在尝试向meteor应用程序添加分页支持,但是一旦我在模板中添加{{{pagination}}}标记,我的模板就会显示一个空白页面。日志中没有错误 我的客户端js(路由信息)如下所示 Meteor.Router.add({ '/': function () { var user; if (Meteor.loggingIn()) { console.log('home: loading'); return 'loading'; } user = Meteor.
Meteor.Router.add({
'/': function () {
var user;
if (Meteor.loggingIn()) {
console.log('home: loading');
return 'loading';
}
user = Meteor.user();
if (!user) {
console.log('homer: signin');
return 'user_signin';
}
// start on 'start' page
console.log('home: start');
return 'page';
},
'/landing': 'landing',
'*': 'not_found',
'/landing/:page': function (page) {
Session.set('page', page) ;
return 'landing' ;
}
});
Template.userList.pagination = function () {
return Pagination.links('/landing', Meteor.users.find({}).count(), {currentPage: Session.get('page'), perPage: 8}) ;
}
我的Landing.js看起来像这样
Meteor.Router.add({
'/': function () {
var user;
if (Meteor.loggingIn()) {
console.log('home: loading');
return 'loading';
}
user = Meteor.user();
if (!user) {
console.log('homer: signin');
return 'user_signin';
}
// start on 'start' page
console.log('home: start');
return 'page';
},
'/landing': 'landing',
'*': 'not_found',
'/landing/:page': function (page) {
Session.set('page', page) ;
return 'landing' ;
}
});
Template.userList.pagination = function () {
return Pagination.links('/landing', Meteor.users.find({}).count(), {currentPage: Session.get('page'), perPage: 8}) ;
}
我的登陆模板如下:
</thead>
<tbody>
{{#each users}}
{{> user}}
{{/each}}
{{{pagination}}}
</tbody>
</table>
{{{#每个用户}}
{{>用户}
{{/每个}}
{{{pagination}}}
我看到了一些关于代码发布的东西
'landing/:page'
之前有通配符'*'
。我相信它会首先匹配那个。应将“*”
作为您添加的最后一条路线我遇到了一个类似的问题,分页包没有呈现结果,而是显示了正确的“next”和“prev”链接。是否正在使用Pagination.Collection呈现结果