简体   繁体   English

Ember.JS视图无法渲染?

[英]Ember.JS view not rendering?

Maybe I'm missing something, but I'm really confused as to why this isn't working: 也许我错过了一些东西,但是我对为什么它不起作用感到非常困惑:

// The Javascript
App.UsersView = Ember.View.extend({
    templateName: 'user-list'
});

// The HTML
<script type="text/x-handlebars" data-template-name="user-list">
    Hello World
</script>

Nothing is displaying? 什么都没显示?

(The application view displays so it's not a problem with the way ember.js is loaded. Just when trying to use custom views.) (显示应用程序视图,因此ember.js的加载方式没有问题。仅在尝试使用自定义视图时。)

The only view/template that is automatically appended to the dom is application. 自动添加到dom的唯一视图/模板是application。 To include UsersView on the page, try: 要在页面上包含UsersView,请尝试:

<script type="text/x-handlebars" data-template-name="application">
  <pre>application view</pre>
  {{view App.UsersView}}
</script>

Working example here: http://jsbin.com/iluvik/1/edit 此处的示例: http : //jsbin.com/iluvik/1/edit

Typically the view helper is not necessary as most of the views/templates your application will get created by the ember router. 通常,视图助手不是必需的,因为您的应用程序的大多数视图/模板将由ember路由器创建。 Have a look at the Ember Routing Guide for a better understanding of how to wire things up. 请参阅《 Ember路由指南》 ,以更好地了解如何进行布线。

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

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