use*_*656 3 pre-compilation handlebars.js ember.js
我正在使用Emebr JS的入门套件,并在应用程序模板中添加了一个带有{{action hello}}的简单锚标签.
我正在使用把手预编译器预编译模板.当我试图运行它时,它会抛出一个错误.
未捕获错误:无法找到属性"操作"
以前我曾经用ember-1.0.pre.js做同样的事情,工作正常.但是当我包含新的ember库(ember-1.0.0-pre.2.js)时,它就抛出了这个错误.
在这两种情况下,我使用的是Handlebars-1.0.rc.1.min.js.
任何人都可以帮我解决问题.下面列出了我正在使用的把手和库的详细信息.
用车把预编译器编译的模板.application.handlebars
<h1>Hello from Ember.js</h1>
<a {{action hello}}>Say Hello!</a>
Run Code Online (Sandbox Code Playgroud)
我的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>
Run Code Online (Sandbox Code Playgroud)
views.handlebars.js包含已编译的把手.
App.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();
Run Code Online (Sandbox Code Playgroud)
在为ember预编译手柄视图时,您需要使用Ember.Handlebars,而不是Handlebars.我怀疑这可能是问题所在.
归档时间: |
|
查看次数: |
973 次 |
最近记录: |