2012-10-23 85 views
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为好,和我仍然有相同的错误(:

+2

很难说没有更多的上下文发生了什么...... –

+0

@ sly7_7 - 就是这样...没有其他东西了,只是一个简单的index.html文件,其中包含jquery和handlebars库( : – Roland

+0

你可以尝试使用非缩小版本,看看什么是未定义的? –

回答

1

Ember Documentation

Every Ember app should have an instance of Ember.Application. This object will serve as the globally-accessible namespace for all of the other classes and instances in your app

这里的关键是“全球”。下面是一个应用程序的示例:

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

你的问题是var -keyword您Application.create。删除它并添加Window以使错误消失。