0

私はEmber.jsで初めて遊んでいて、最初のハードルに落ちています。これを機能させるために何年も努力してきましたが、「未定義のメソッド'extend'を呼び出せません」というエラーが発生し続けます

私のHTMLにはこれがあります:

<script type="text/x-handlebars">
    {{#view App.MainView}}
      <div class="hero-unit">
        <h1>{{blogTitle}}</h1>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur non neque a eros dapibus posuere. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
      </div>
    {{/view}}
  </script>

そして私のJSにはこれがあります:

var App = Ember.Application.create();

//define main view
App.MainView = Ember.View.extend({
    blogTitle: 'Epic Blog'
});

ドキュメントによると、これでテンプレートが正常にレンダリングされるはずですが、どんなに頑張ってもエラーが発生します...

誰かが私が間違っていることを知っていますか?

4

1 に答える 1

2

使用している Ember.js のバージョンは何ですか? Ember.js 0.9.8.1 を使用してコードで JSFiddle を作成しましたが、動作します。 http://jsfiddle.net/pangratz666/D3VuA/を参照してください。

Appまた、.を省略してグローバル変数として宣言する必要がありますvar。これは、テンプレートのバインディングとパスが機能するために必要です。

App = Ember.Application.create();
...
于 2012-07-03T11:31:38.620 に答える