dojo 1.7,在子类'中设置ContentPane的内容;建造师
我有以下派生自ContentPane的子类:dojo 1.7,在子类'中设置ContentPane的内容;建造师,dojo,dijit.layout,Dojo,Dijit.layout,我有以下派生自ContentPane的子类: define([ "dijit/layout/ContentPane", "dojo/_base/declare" ], function (ContentPane, declare) { var view = declare("client.View", ContentPane, { html: null, constructor: f
define([
"dijit/layout/ContentPane",
"dojo/_base/declare"
],
function (ContentPane, declare) {
var view = declare("client.View", ContentPane, {
html: null,
constructor: function (args) {
declare.safeMixin(this, args);
if (this.html !== null) {
this.set("content", this.html);
}
}
});
return view;
}
);
现在,以下代码在“this.set(“content”,this.html);”行上抛出TypeError:
var html=“你好”;
var view=view(html);
如何正确设置ContentPane的内容?Ken Benjamin回答了我关于Dojo社区的问题(http://dojotoolkit.org/community/): 您试图在小部件生命周期中过早设置内容。尝试在postCreate而不是构造函数中执行此操作 在此处阅读有关小部件生命周期的更多信息:
var html = "<div>Hello</div>";
var view = View(html);