簡體   English   中英

Ember.JS視圖無法渲染?

[英]Ember.JS view not rendering?

也許我錯過了一些東西,但是我對為什么它不起作用感到非常困惑:

// 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>

什么都沒顯示?

(顯示應用程序視圖,因此ember.js的加載方式沒有問題。僅在嘗試使用自定義視圖時。)

自動添加到dom的唯一視圖/模板是application。 要在頁面上包含UsersView,請嘗試:

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

此處的示例: http : //jsbin.com/iluvik/1/edit

通常,視圖助手不是必需的,因為您的應用程序的大多數視圖/模板將由ember路由器創建。 請參閱《 Ember路由指南》 ,以更好地了解如何進行布線。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM