【问题标题】:How do I render multiple outlets in one template file using ember 2.3如何使用 ember 2.3 在一个模板文件中渲染多个插座
【发布时间】:2016-01-26 07:11:59
【问题描述】:

我正在尝试将多个 .hbs sn-ps 渲染到它们各自的插座中。但是,下面的 renderTemplate 不起作用:

renderTemplate: function() {
     // default behavior, renders the home template
     this.render(); 
      this.render('hero', {    // render the `hero` template
       outlet: 'hero'  // using the outlet named `hero`
     });
   }, 

有问题的模板文件如下所示:

{{outlet 'hero'}}
{{outlet}}

这实际上渲染了默认模板(这是索引路由)两次:一次在 hero 出口,一次在常规出口。

这似乎在 ember1.7 中有效,即使 hero 出口包含在 application.hbs 模板中。 ember2.3 并非如此。

我将如何进行这项工作?

【问题讨论】:

  • ^ 我复制并粘贴了您的代码(在适当的位置),现在它似乎可以工作了。我不确定我首先做错了什么,但现在它正在工作。也许这是我造成的某种构建问题。

标签: ember.js ember.js-2


【解决方案1】:

在 Ember 2.0 中,有很多 changes。我认为thisthis 与您的情况最相关。 如果我没记错的话,Ember 2.x 的方式现在是 components

【讨论】:

    猜你喜欢
    • 2014-01-15
    • 1970-01-01
    • 1970-01-01
    • 2015-10-06
    • 1970-01-01
    • 2013-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多