0

EmberJSの学習を開始しましたが、コンソールに次のエラーが表示されます。

Uncaught TypeError: Cannot call method 'proto' of undefined ember-1.0.pre.min.js:17

ライブラリを含めるだけで、そのエラーが発生するようです。なぜ私がそれを得るのか誰かが知っていますか?

編集:HTMLマークアップを追加

<!doctype html>

  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title></title>
    <meta name="description" content="">
    <meta name="author" content="">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="apple-touch-icon" href="/apple-touch-icon.png">
    <link rel="stylesheet" href="css/style.css?v=2">

    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
  </head>
  <body>
    <script type="text/x-handlebars">
      {{#view App.MyView}}
        <h1>Hello world!</h1>
      {{/view}}
    </script>

    <!-- The missing protocol means that it will match the current protocol, either http or https. If running locally, we use the local jQuery. -->
    <script src="js/libs/jquery-1.7.2.min.js"></script>
    <script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.2.min.js"><\/script>')</script>
  <script src="js/libs/handlebars-1.0.0.beta.6.js"></script>
  <script src="js/libs/ember-1.0.pre.js"></script>
  <script src="js/app.js"></script>
  </body>
  </html>

また、ファイルにはこのJSがありapp.jsます:

var App = Em.Application.create();

App.MyView = Em.View.extend({
  mouseDown: function() {
  window.alert("hello world!");
}
});

しかし、それは削除されており、HTMLからすべてのテンプレート部分も削除されており、それでも同じエラーが発生します(:

4

1 に答える 1

1

Emberドキュメントから:

すべてのEmberアプリには、Ember.Applicationのインスタンスが必要です。このオブジェクトは、アプリ内の他のすべてのクラスとインスタンスのグローバルにアクセス可能な名前空間として機能します

ここで重要なのは「グローバル」です。アプリケーションの例を次に示します。

window.App = Ember.Application.create();

あなたの問題はあなたのvar-キーワードApplication.createです。それを削除して追加Windowすると、エラーが消えます。

于 2012-10-24T06:09:08.053 に答える