【问题标题】:Meteor 0.80 new template displaying only [object Object] on my appMeteor 0.80 新模板在我的应用程序上仅显示 [object Object]
【发布时间】:2014-05-16 12:02:56
【问题描述】:

这是我看到的所有渲染结果:[object Object]

我需要修改什么?

我的文件:

layout.html

<template name="layout">
  <div class="container">
    <div class="row">
      {{yield}}
    </div>
  </div>
</template>

post_page.html

<template name="postPage">
  <div class="sidebar col-md-4">
    {{#each posts}}
      {{> postItem}}
    {{/each}}
    <a class="save-all" href="javascript:;"><span class="glyphicon glyphicon glyphicon-save"></span></a>
  </div>

  <div class="mainbar col-md-12">
    {{> postSubmit}}
  </div>
</template>

post_page.coffee

Template.postPage.helpers posts: ->
  Posts.find {},
    sort:
      position: 1

routes.coffee

Router.configure layoutTemplate: "layout"
Router.map ->
  @route "home",
    path: "/"
    template: "home"

  @route "postPage",
    path: "/posts/:_id"
    data: ->
      Posts.findOne @params._id

post.coffee

@Posts = new Meteor.Collection "posts"

【问题讨论】:

    标签: meteor


    【解决方案1】:

    对于 0.8,您需要这样做:{{&gt; yield}} 而不是 {{yield}}

    【讨论】:

      【解决方案2】:

      是的,从 Blaze 开始,正如 herehere 所述,您需要稍微更改模板的语法:

      layout.html

      <template name="layout">
        <div class="container">
          <div class="row">
            {{> yield}}
          </div>
        </div>
      </template>
      

      【讨论】:

        【解决方案3】:

        路由器已被弃用。使用来自陨石的Iron-Router,参考docs

        Router.map(function() {
         this.route('postslist', {path: '/'})
        //read the docs for your next routing needs
        

        });

        这是与question类似的帖子

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-10-21
          • 2019-06-16
          • 1970-01-01
          • 1970-01-01
          • 2020-06-17
          • 2023-02-23
          • 1970-01-01
          • 2018-04-19
          相关资源
          最近更新 更多