【发布时间】:2017-02-10 17:40:32
【问题描述】:
我尝试使用以下模板模型来做到这一点:
<div>
<div data-dojo-attach-point="includeHere"</div>
</div>
和
<div>
${includeHere}
</div>
然后在课堂上我认为应该是这样的:
define([
"dojo/_base/declare",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dojo/text!./templates/myWidget.html",
"dojo/text!./templates/templateToBeIncluded.html"
], function (
declare,
_WidgetBase,
_TemplatedMixin,
template,
templateToBeIncluded
) {
return declare([_WidgetBase, _TemplatedMixin], {
templateString: template,
buildRendering: function() {
this.includeHere = templateToBeIncluded;
},
});
});
我查看了 _TemplatedMixin 源并尝试根据 _TemplatedMixin 的方式更改 buildRendering 函数:
buildRendering: function() {
domConstruct.toDom(templateToBeIncluded, this.includeHere);
},
但也无法让它发挥作用。这样做的正确方法是什么?我不想在我的 .js 文件中包含 HTML。我只想在模板中使用 HTML。
【问题讨论】:
-
为什么需要这个?您是否需要在另一个小部件中包含一个小部件?能帮上忙吗? stackoverflow.com/questions/9306670/…
-
嗯...我还是从 Dojo 开始的。也许我没有得到做事的“道场方式”。但实际上我的想法是我不需要小部件内的小部件......我只需要一个子模板。但仔细想想,这几乎是一样的,不是吗?嗯...你认为我应该将子模板转换为小部件吗?
标签: javascript templates dojo