我目前正在使用asp.net的emberjs模板,我想知道如何在单独的文件中添加组件?
模板使用Handlebars编译器添加文件,认为我在尝试包含编译器的子文件夹时遇到问题,因为组件tempaltes被命名为data-template-name =“components / example”,I无法使用“/”命名文件。以下是如何包含文件的示例:
bundles.Add(new ScriptBundle("~/bundles/app").Include(
"~/app/app.js",
"~/app/router.js",
"~/app/helpers.js"
).IncludeDirectory("~/app/routes", "*.js")
.IncludeDirectory("~/app/models", "*.js")
.IncludeDirectory("~/app/views", "*.js")
.IncludeDirectory("~/app/controllers", "*.js")
);
至少对于partials,您可以简单地命名文件“_partial”,它们将被添加为data-template-name =“_ partial”并将进行编译。以下是如何包含把手文件:
bundles.Add(new Bundle("~/bundles/templates",
new EmberHandlebarsBundleTransform()).IncludeDirectory("~/app/templates\\", "*.hbs", true)
);
答案 0 :(得分:0)
关键是你不能将Ember.Component命名为components / example。它必须用' - '分隔。
将组件模板放入〜/ app / templates / components / * .hbs中,然后只包含该目录。编辑将由Ember完成,但我建议你使用具有预编译功能的把手。更好的表现方式。