简体   繁体   English

Ember的模板渲染管道

[英]Ember's template rendering pipeline

I have a specific template for both the main app and the public facing pages. 我对主应用程序和面向公众的页面都有特定的模板。 Based on the docs the code below is what I thought should work. 根据文档,以下代码是我认为应该起作用的代码。 However I continually get a Cannot read property 'connectOutlet' of undefined error thrown. 但是,我不断得到抛出Cannot read property 'connectOutlet' of undefined错误的Cannot read property 'connectOutlet' of undefined

router.js router.js

Router.map(function() {
  this.route('app');
  this.route('login');
});

application.hbs application.hbs

{{outlet}}

public.hbs public.hbs

This is the public template
{{outlet}}

app.hbs app.hbs

This is the app template
{{outlet}}

login.hbs login.hbs

<input type="email" ...>
<input type="password" ...>

routes/login.js 路线/ login.js

import Ember from "ember";

export default Ember.Route.extend({
  renderTemplate: function() {
    this.render('login', { into: 'public' });
  }
});

routes/app.js 路线/ app.js

import Ember from "ember";

export default Ember.Route.extend({
  renderTemplate: function() {
    this.render('login', { into: 'public' });
  }
});

If I remove the {into:..} options no error is thrown but both the login and app templates are rendered into the application template rather then the public and app respectively. 如果我删除了{into:..}选项,则不会引发任何错误,但是登录模板和应用程序模板都会呈现到应用程序模板中,而不是分别呈现到公共和应用程序中。

Am I totally misunderstanding how Ember handles the rendering? 我是否完全误解了Ember如何处理渲染?

In the app that I'm doing with ember I also use the renderTemplate hook to render a template into another one, your code there is the same as mine and looks good. 在我使用余烬的应用程序中,我还使用renderTemplate钩子将模板渲染为另一个模板,您的代码与我的相同,并且看起来不错。

I think the problem might be that there isn't any public route. 我认为问题可能在于没有任何公共路线。 I think that if you define one in your router, and then try again, it may work. 我认为,如果您在路由器中定义一个,然后再试一次,则可能可行。 Looks to me like its not able to render the templates into public because public does not exist. 在我看来,由于公共不存在,它无法将模板公开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM