【问题标题】:Why doesn't this template code from the Discover Metor book work?为什么 Discover Metor 书中的这个模板代码不起作用?
【发布时间】:2014-06-07 13:45:09
【问题描述】:

通过“发现流星”一书我的方式。关于创建包含特定帖子链接的 postItem 模板的代码表单章节根本不起作用(没有错误,但也没有结果)。

查看我正在使用的代码的链接要点 [1]。控制台中没有错误。我还阅读了有关 Blaze 的 Meteor 0.8 中引入的更改,我怀疑这是导致问题的原因,但是,文档似乎建议在我的情况下使用模板助手是相同的[2],我可以从查看各种流星创建的脚本,例如 router.js,至少尝试支持较旧的模板系统 [3]。

为什么这段代码不起作用?有没有办法只做一些微小的改变来让它工作,而不是转移到 Iron-router 并且可能与我正在使用的 Discover Meteor 版本相差太远?

[1] 客户端/视图/posts/post_item.html:https://gist.github.com/Trindaz/11139437; client/helpers/router.js: https://gist.github.com/Trindaz/11139409;

[2] http://meteorpedia.com/read/Blaze_Notes#Template Helpers [注意:此链接中“Helpers”之前的空格会破坏它] 这似乎更多地是关于块助手而不是我使用助手的方式,但似乎是任何讨论的范围关于助手的使用,所以我假设其他一切都保持不变。

[3]https://github.com/tmeasday/meteor-router/blob/master/lib/router_client.js#L88

【问题讨论】:

    标签: meteor meteorite meteor-blaze


    【解决方案1】:

    写完这篇文章后,我几乎立即找到了答案,留给未来的谷歌人。

    问题似乎是由https://github.com/tmeasday/meteor-router/blob/v0.6.1/lib/router_client.js#L89-L90UI.body 成员分配引起的。这打破了 Meteor 0.8.0-rc3 https://groups.google.com/forum/#!msg/meteor-talk/oatU1zzcaeQ/54ay-pPlRrwJ 中引入的更改。

    从版本中:“模板不再自动访问祖先的助手 [11]。如果您使用 UI.body.helpers 声明助手,则需要切换到 UI.registerHelper。”

    现在这可能都是多余的,因为工作已经转移到 Iron-router。

    【讨论】:

      猜你喜欢
      • 2011-04-11
      • 1970-01-01
      • 2019-04-15
      • 2018-11-05
      • 2012-02-22
      • 2023-03-03
      • 2017-10-02
      • 2016-07-10
      • 2010-12-14
      相关资源
      最近更新 更多