我正在使用来自 Emebr JS 的入门工具包,并在应用程序模板中添加了一个带有 {{action hello}} 的简单锚标记。
我正在使用把手预编译器预编译模板。当我尝试运行它时,它会引发错误。
未捕获的错误:找不到属性“操作”
以前我用ember-1.0.pre.js做同样的事情,效果很好。但是当我包含新的 ember 库(ember-1.0.0-pre.2.js)时,它会抛出这个错误。
在这两种情况下,我都使用handlebars-1.0.rc.1.min.js。
谁能帮我解决这个问题。下面列出了我正在使用的车把和库的详细信息。
使用车把预编译器编译的模板。应用程序.handlebars
<h1>Hello from Ember.js</h1>
<a {{action hello}}>Say Hello!</a>
我的 HTML 页面:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.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.0-pre.2.min.js"></script>
<script src="handlebars/compiled/views.handlebars.js"></script>
<script src="js/app.js"></script>
views.handlebars.js 包含已编译的车把。
应用程序.js:
var App = Ember.Application.create();
App.ApplicationController = Ember.Controller.extend();
App.ApplicationView = Ember.View.extend({
templateName: 'application'
});
App.Router = Ember.Router.extend({
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/'
}),
hello: function() {
console.log("Hello and Welcome");
}
})
})
App.initialize();