对于我的 EmberJS 应用程序,我预编译了我所有的 handlebars 模板,因此它们作为直接的 Javascript 文件加载。
问题是这些预编译模板没有像我想象的那样进入 Ember 容器 - 当我为我的 View 指定模板时,我收到以下错误。
Uncaught Error: assertion failed: You specified the templateName "application" for <MyApp.ApplicationView:ember164>, but it did not exist.
这是我的 View 代码。
window.MyApp.ApplicationView = Ember.View.extend({
templateName: 'application'
});
我单步执行,发现 View 不存在于 Ember 容器中。我需要做些什么来向容器注册预编译模板吗?如果是,怎么办?
编辑:我一直在使用 handlebars npm 包编译模板。
最佳答案
在 Ember.TEMPLATES
上查找模板(这只是一个以模板名称作为键的哈希值)
因此,当您的示例 ApplicationView
被执行时,它将在 Ember.TEMPLATES['application']
中查找模板
关于javascript - EmberJS - 注册预编译的 Handlebars 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15168323/