javascript - 使用 Meteor-Pages 实现分页时出错

标签 javascript pagination meteor

我指的是Meteor-Pages的基本演示。

基本演示 https://github.com/ianpogi5/meteor-pages/tree/master/examples/basic .

Meteor 页面 https://atmospherejs.com/package/pages .

这个想法是创建分页并在每页显示 1 个推荐。

浏览器上没有显示任何内容,并且我遇到了以下错误:

Uncaught TypeError: Cannot set property 'pagesData' of undefined 

Exception from Deps recompute function: Error: Expected null or template in return value     
from inclusion function, found: [object Object]

我的代码是:

页面.咖啡

@Pages = new Meteor.Pagination 'Recommendations',
  perPage: 1

推荐.咖啡

@Recommendations = new Meteor.Collection("recommendations")

recommendations_list.html

<template name="recommendationsList">
 <h1>Recommendations for each user</h1>
  <div>
   {{#each recommendations}}
    {{> recommendationItem}}
   {{/each}}
  </div>

  {{> recommendations}}
</template>

<template name="recommendations">
 {{> pagesNav}}
 {{> pages}}
</template>

最佳答案

已解决,之前的代码有两处错误。以下是修改后的内容。

推荐.咖啡

@Recommendations = new Meteor.Collection("recommendations")

// Pagination must put directly under the collections, because we want to run the 
// collection first before making the pagination

@Pages = new Meteor.Pagination Recommendations,
  perPage: 1    

recommendations_list.html

<template name="recommendationsList">
 <h1>Recommendations for each user</h1>
  <div>
  {{> recommendations}}
  </div>
</template>

<template name="recommendations">
 {{> pagesNav}}
 {{> pages}}
</template>

关于javascript - 使用 Meteor-Pages 实现分页时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23556680/

相关文章:

javascript - 单击时隐藏 CSS 菜单

java - 如何返回仅包含短页面信息的分页代码?

angularjs - 使用 ng-table 进行分页

javascript - 延迟 meteor 功能加载

javascript - Meteor 中的路由

javascript - 在 Chart.js 中更改折线图上特定点的大小

javascript - 使用 JavaScript 选择 CSS 主题

javascript - 当用户向下滚动时,如何使侧边栏停在特定的 div 处?

Laravel 5.4 分页与关系

javascript - Meteor.publish 回调需要在 Fiber 中包装