本文介绍了Emberjs手把预编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Emberjs应用程序运行缓慢,所以我想预编译我的模板以简化运行时。但是我失去了如何进行。我阅读了和Emberjs介绍,但不能,我只能创建一个模板文件按照网站上的指示,我无法弄清楚在Emberjs中使用此模板文件的方法和方法。

My Emberjs app is running slowly so I wanted to precompile my template to ease the runtime a bit. However I'm lost on how to proceed. I read http://handlebarsjs.com/precompilation.html and Emberjs introduction but no, all I could do was just creating a template file as instructed on the site, and I cannot figure out what and how to do with this template file in Emberjs.

如何在Emberjs中预编译模板?您应该如何使用模板文件在Emberjs中使用?

How can I precompile templates in Emberjs? What should I do with the template file to use it in Emberjs?

推荐答案

您可以将预编译的句柄输出设置为模板属性(不是templateName)在你的ember视图。这是Ember还是在引擎盖下。

You can set the precompiled handlebars output to the template property (not templateName) on you ember view. This is what ember also does under the hood

MyApp.MyView = Ember.View.extend({
  templateName: "myViewWhatever",
  template: Ember.Handlebars.compile('<p>{{blah}}</p>'),
})

这篇关于Emberjs手把预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 20:24